Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] select


  • From: andyg at ihug.co.nz (Andrew Gibson)
  • Subject: [Javascript] select
  • Date: Thu Mar 27 15:46:32 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