Jump to content

Write Something From Radio Button Choice


bigsilk
 Share

Recommended Posts

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

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>

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...