Hello, Javascript is not my cup of tea but I'm faced with a client that wants it a certain way.
I need to hide/display a DIV when you click on a form dropdown. Here's the not functioning code.
Code:
<style type="text/css">
#one,#two,#three{visibility:hidden;position:absolute;height:200px;width:300px;}
</style>
<script type="text/javascript">
function radFlip(){
var l=document.firstForm.dropdown.radOne.length;
for(var i=0;i<l;i++){
var to_see=document.firstForm.dropdown.radOne[i].value;
if(document.firstForm.dropdown.radOne[i].selected){
document.getElementById(to_see).style.visibility="visible";
}else{
document.getElementById(to_see).style.visibility="hidden";
}
}
}
</script>
Code:
<form action="" name="firstForm" onclick="radFlip();">
<select name="dropdown">
<option name="radOne" value="one" selected>One</option>
<option name="radOne" value="two">Two</option>
<option name="radOne" value="three">Three</option>
</select>
</form>
<div id="one">test 1</div>
<div id="two">test 2</div>
<div id="three">test 3</div>
I think the first problem is the script is not recognizing the form, and the second is I don't know if the .selected will actually work.
If anyone could shed some light. THANKS!!!
__________________
Jdawg
Sirius Solutions
"I know because I must know, it is my purpose" - keymaker
|