bigsilk Posted October 26, 2009 Share Posted October 26, 2009 I'm trying to get a reaction from a radio button choice: If a person chooses 'Single', nothing happens. If they choose 'Married', an input box appears to allow them to enter their spouse's name. <html><head><script type="text/javascript"> { document.getElementById("answer"); } if (value = married) { document.write("Spouse's Full Name: <input type="text" size="20">"); }</script></head><body><form>Your Marital Status: <input type="radio" name="answer" onclick="check(this.value)" value="single">Single<input type="radio" name="answer" onclick="check(this.value)" value="married">Married<br /></form></body></html> Link to comment Share on other sites More sharing options...
dsonesuk Posted October 26, 2009 Share Posted October 26, 2009 try this:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script type="text/javascript">/*<![CDATA[*//*---->*/ function check(value) { document.getElementById("answer"); if (value =="married") { document.getElementById("spouse").style.display="block"; } else { document.getElementById("spouse").style.display="none"; } }/*--*//*]]>*/</script> <style type="text/css">#spouse{display:none;}</style></head><body><form action="#">Your Marital Status:<input type="radio" name="answer" onclick="check(this.value)" value="single" />Single<input type="radio" name="answer" onclick="check(this.value)" value="married" />Married<br /><div id="spouse">Spouse's Full Name: <input type="text" size="20" /></div></form></body></html> Link to comment Share on other sites More sharing options...
bigsilk Posted October 26, 2009 Author Share Posted October 26, 2009 You've come through again. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.