Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Radio button if selected drop down

    I NEED HELP, SERIOUSLY!!! I've been trying to figure this out for weeks....

    I want to add RADIO BUTTONS in my page that will respond based on YES OR NO.

    For example:

    I will have a RADIO BUTTON YES... and another NO.
    If I select YES right underneath it , TEXT X will come up. IF I select NO, TEXT Y will come up.. and so on..


    The answer to the radio button will appear right under the YES or NO. I hope I was as clear as possible.

    I work for NESTLE and I am creating a small web site for them. My job is your hand LOL

    THANKS

  • #2
    New Coder
    Join Date
    Jul 2006
    Location
    California
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Something like this?
    Code:
    <script type="text/javascript">
    	
    	function writeText_yes() 
    	{
    		document.getElementById("dynamic").innerHTML="<select name=\"yes_dropdown\"><option value=\"\">Select something</option><option value=\"1\">1</option><option value=\"2\">2</option></select>"
    	}
    	function writeText_no() 
    	{
    		document.getElementById("dynamic").innerHTML="<select name=\"no_dropdown\"><option value=\"\">Select something 2</option><option value=\"1\">3</option><option value=\"2\">4</option></select>"
    	}
    </script>
    <h3>Javascript Radio Buttons and Texy </h3>
    <form id="form" name="form" method="post" action="">
      <input onClick=" writeText_yes()" name="radiobutton" type="radio" value="radiobutton" />
      Yes
      <input onClick="writeText_no()" name="radiobutton" type="radio" value="radiobutton" />
      No<br />
    <p id="dynamic">Please click on a radio button to see a list.</p>
    
    <input type="submit" name="Submit" value="Submit">
    </form>
    Example: http://dev.dorkzville.com/javascript/javascript001.html

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    WOW Thanks Lordrea for the fast response. That is ALMOST what i am looking for...

    In my example I want instead of a drop down menu... just simple text... and no submit button...

    For example:

    I have a YES and NO radio buttons. If I click yes I get TEXT A, if i click on NO, I get TEXT B....

    if I click on RADIO BUTTON YES

    TEXT A apperas: Is your coffee machine working?
    (YES radio button).....(MAY BE Radio button)


    ----------------------------------------

    If I click on radio button NO

    TEXT B appears: Is your machine plugged in? Radio Button YES, radio button NO

    Its basically a troubleshooting steps, with yes or no's to determ the problem. And there are 4 steps...

    I'll be happy to get a response from you... and im so thankful for your help

  • #4
    New Coder
    Join Date
    Jul 2006
    Location
    California
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's easy to fix:
    Code:
    <script type="text/javascript">
    	
    	function writeText_yes() 
    	{
    		document.getElementById("dynamic").innerHTML="TEXT A"
    	}
    	function writeText_no() 
    	{
    		document.getElementById("dynamic").innerHTML="TEXT B"
    	}
    </script>
    <h3>Javascript Radio Buttons and Texy </h3>
    <form id="form" name="form" method="post" action="">
      <input onClick=" writeText_yes()" name="radiobutton" type="radio" value="radiobutton" />
      Yes
      <input onClick="writeText_no()" name="radiobutton" type="radio" value="radiobutton" />
      No<br />
    <p id="dynamic">Please click on a radio button to see a list.</p>
    </form>
    If you want to send the data via post, you can put the text in textfields so they can be sent along with the other data. though with no submit button, I don't think that matters :P

    If you want/need to me explain the code step-by-step so you can easily edit it later, I'd be glad to do so.
    Last edited by Lordrea; 07-04-2006 at 05:54 AM.

  • #5
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes that's it... awesome..

    ... now what If after I select TEXT B and I still want a YES and NO radio button question for TEXT B...

    For examaple,
    I selected NO, TEXT B comes up... and there is another YES and NO radio button for TEXT B, know what I am mean?

    How do I do that?

  • #6
    New Coder
    Join Date
    Jul 2006
    Location
    California
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That may be a little trickier... I can take time to write it... but you should :P

    Code:
    function writeText_yes() 
    {
    	document.getElementById("dynamic").innerHTML="TEXT A"
    }
    This code takes the text and edits it to what you want. You would have to use multiple <P> fields with different IDs, and more functions for every choice. Now, you could do this another way, but I can't think of it right now. I'll think about it for a bit for ya.

  • #7
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Lordrea
    That may be a little trickier... I can take time to write it... but you should :P

    Code:
    function writeText_yes() 
    {
    	document.getElementById("dynamic").innerHTML="TEXT A"
    }
    This code takes the text and edits it to what you want. You would have to use multiple <P> fields with different IDs, and more functions for every choice. Now, you could do this another way, but I can't think of it right now. I'll think about it for a bit for ya.

    Oh so complicates it? Eh sorry. but thanks tho


  •  

    Posting Permissions

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