[Javascript] select
Andrew Gibson
andyg at ihug.co.nz
Thu Mar 27 15:46:12 CST 2003
The effect I want to achieve is, when selecting cat, an asterisk is placed
in the cell next to cat in the table. When dog is selected, the asterisk is
removed from cat row and an asterick is placed in the dog row. Kelly
===========================================================
Would this work?
<form>
<select onChange=test(this.form) size="1" name="pet" >
<option value="Select">Select</option>
<option value="Dog">Dog</option>
<option value="Cat">Cat</option>
</select>
</form>
<table>
<tr><td id=Dog>Dog</td></tr>
<tr><td id=Cat>Cat</td></tr>
</table>
<script>
var curPet="";
function test(frm)
{
if(curPet!=""){
document.getElementById(curPet).innerHTML=curPet;
}
var pet=frm.pet.options[frm.pet.selectedIndex].value
document.getElementById(pet).innerHTML="*"+pet
curPet=pet
}
</script>
Cheers
Andrew Gibson
More information about the Javascript
mailing list