I was wondering if someone could help me out with a small piece of javascript…
What i wanna achieve:
I want a dropdown menu to become ‘visible’ when a checkbox has been checked,… and here’s the key, i want it to become visible imidiately, not when a form has been submitted…
Can anyone help me out with this one?
Thanks!
deleeuw.
so NOT something like:
<script type="text/javascript">
function DoTheCheck() {
if(document.myform.box1.checked == true)
{ alert('box1 is checked'); }
if(document.myform.box1.checked == false)
{ alert('box1 is not checked'); }
if(document.myform.box2.checked == true)
{ alert('box2 is checked'); }
if(document.myform.box2.checked == false)
{ alert('box2 is not checked'); }
}
</script>
<form name="myform" method="POST" action="#">
<input type="checkbox" name="box1" value="yes1">
<input type="checkbox" name="box2" value="yes2">
<input type="submit" onClick="DoTheCheck()">
</form>
Hmm, it didn’t occur to me to check in IE6. IE6 doesn’t seem to like the onchange bit, probably because there’s only one checkbox. Use this javascript instead:
window.onload = function() {
var c = document.getElementById('platypus');
c.onclick = function() {
if (c.checked == true) {document.getElementById('answer').style.display = 'inline';}
else {document.getElementById('answer').style.display = '';
}
}
}
Can you make this script work when 2 radio buttons are used, instead of a checkbox,…
So the unselected radio doesnt show any other option, while the selected radio box shows a dropdown menu… Ofcourser when the other radiobox is selected it reacts the same, the previous selected radiobox doesn’t show anything else, while the selected one now does show a dropdown menu.