Text Updates DHTML

[Total: 0    Average: 0/5]

This shows how to have a text or select list choice change text on the page.

Head Code:

<style type="text/css"> 
#mytext{cursor:hand;} 
.redtext{color:#ff0000;} 
.bluetext{color:0000ff;} 
</style> 
<script language="JavaScript" type="text/javascript"> 
function changeclass(thediv,msg) {
  thediv.className=(thediv.className=="redtext")?"bluetext":"redtext";
  thediv.innerText=msg;
}
</script> 

Body Code:

this is not supported by NS
<div id="mytext" class="redtext" onclick="changeclass(this,'hi')">Click this to change.</div> 
<form name=exf1>
<select name=sel onchange=doIt(this,this.selectedIndex)>
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
</select>
</form>
<script>
function doIt(_f,_SI)
{
changeclass(document.all.mytext,_f[_SI].text);
}
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *