SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist jor133d's Avatar
    Join Date
    Jul 2003
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    radio button to textbox

    Hello.

    I was wondering if someone can help me out. I have 2 radio buttons and a textbox. I would like it so when I click one radio button, a some text shows up in that box and if someone clicks the other, some other text appears in the textbox.

    Can someone help me out of where to start?

    Thanks!

  2. #2
    SitePoint Evangelist jor133d's Avatar
    Join Date
    Jul 2003
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about that, I figure it out already. Disregard my post.

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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 language="javascript" type="text/javascript">
    function FillText(fm){
    	if(fm.rd1[0].checked == true){
    		fm.flt.value = "First radio is clicked.";
    	}
    	else if(fm.rd1[1].checked == true){
    		fm.flt.value = "Second radio is clicked.";
    	}
    	else{
    		fm.flt.value = "";
    	}
    }
    </script>
    </head>
    
    <body>
    <form id="form1" method="post" action="">
      <p>
        <input name="rd1" type="radio" id="rd1" value="Yes" onclick="FillText(this.form);" />
      Yes 
      <input name="rd1" type="radio" id="rd1" value="No" onclick="FillText(this.form);" />
      No
      <input name="flt" type="text" id="flt" />
      </p>
    </form>
    </body>
    </html>
    Does this help your case?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •