On Apr 4, 2:13 am, "Kulgan" <nos...@skynet.bewrote:
What happens if the third is clicked and then the first one is clicked?
Does the textbox
stay or does it go?
If the first or the second radiobutton is clicked the textbox must disapear
again ...
It is easier to hide/show the textbox though.
That would be a great solution, but how to do it ?
thanks!
You can start with this and fine tune as necessary:
<script type="text/javascript">
function checkIt(el) {
if (el.value == "other") {
document.getElementById('text').style.display = "block";
}
else {
document.getElementById('text').style.display = "none";
document.getElementById('who').value = '';
}
}
</script>
<input type="radio" name="radio" value="one"
onclick="checkIt(this);">One
<input type="radio" name="radio" value="two"
onclick="checkIt(this);">Two
<input type="radio" name="radio" value="other"
onclick="checkIt(this);">Other <br>
<div id="text" style="display:none;">Other: <input type="text"
id="who"/></div>
This puts the textfield in a hidden div. If one or two is checked, the
textbox is hidden and it's value is reset (so you don't accidently
submit a value, you could always change this behaviour as your server
side should be checking the value of "radio" for "other" before it
attempts to process a "who" value). If other is checked, the textfield
is displayed.
HTH.