Thread: Please Help
-
January 22nd, 2010, 07:14 PM #1Junior Member
- Join Date
- Jan 2010
- Posts
- 1
Please Help
I'm creating a form for my website. I have a series of yes no questions with radio buttons. When the user clicks yes, I would like a text box to appear. Here is the code I'm using
/* CSS */
form input[name="text1"]
{
display: none;
}
/* SCRIPT */
<script type="text/javascript">
function checkIt(el) {
if (el.value == "other") {
document.forms['form1'].elements['text1'].style.display = "block";
}
else {
document.forms['form1'].elements['text1'].style.display = "none";
document.forms['form1'].elements['text1'].value = '';
}
}
</script>
/* MARKUP */
<form name="form1">
<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>
<input type="text" name="text1" />
</form>
The issue being, it's not hiding the textbox when no is checked. Keep in mind this is a very small version of the code I'm using. If I have just one yes or no question it seems to work fine, it's when I add it to the other questions that I have problems.
Will I have to create different instance for each question to get this to work properly??
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)



LinkBack URL
About LinkBacks



Reply With Quote

Use vinegar on your skin tonight and finish with 100% aloe vera lotion. My mom died this morning in her sleep. Just the way she would have wanted it, and while not quiet as soon as she wanted, it...
Is It Just Me? v233893843