
August 17th, 2004, 06:58 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 5
Time spent in forums: 32 m 12 sec
Reputation Power: 0
|
|
Select field does not seem to select
I have this nice dynamic select field that when a user clicks on a selection
it shows the <div> according to the value. There is just one problem, as you can see
I have the menu selected as default on the "Beach" option, now when the page first loads it does not
display the code that is for the beach <div> a user would have to click on another option and then click back.
Would anyone know how they may be able to modify this so by default it would also display the Beach code?
Code:
<script>
function showForm(index){
frms=document.getElementsByTagName('div')
for (i=0;i<frms.length;i++)
frms[i].style.display='none'
frms[index].style.display='block'
}
</script>
<select size="5" onchange="showForm(this.options[selectedIndex].value)">
<option value="1">Sand</option>
<option value="0" selected>Beach</option>
</select>
<div name="item" style="display:'none'">Code for Sand
</div>
<div name="item" style="display:'none'">Code for Beach
</div>
Thanks
|