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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Radio Button Print Code

    I am looking for a piece of code that will PRINT code directly below a group of radio buttons depending on which button is selected. I have been accomplishing this using JavaScript and DIV tags, but this solutions isn't going to work.

    [ ] Option 1
    [ ] Option 2
    [X] Option 3

    Here is the text from option three!

    If nothing is selected, I would like nothing to print. If someone could help me get started with this, I would be VERY appreciative. I am a bit of a PHP hack and have tried NUMEROUS things to no availe. I really appreciate any help!

    THANKS!
    Kyle
    Last edited by Kobescent; 04-27-2006 at 11:09 PM.

  • #2
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Is this what you're looking for?
    Code:
    <html>
    <head>
    <script type="text/javascript"><!--
      var optText = ["Option one is selected.", "Option two is selected.", "Option three is selected." ];
    
      function changeMe(n) {
        document.getElementById("optionText").innerHTML = optText[--n];
      }
    --></script>
    </head>
    <body>
    
    <input type="radio" name="groupName" onclick="changeMe(1);" />Option 1<br/>
    <input type="radio" name="groupName" onclick="changeMe(2);" />Option 2<br/>
    <input type="radio" name="groupName" onclick="changeMe(3);" />Option 3<br/>
    
    <div id="optionText">starting text</div>
    
    </body>
    </html>
    My Website: DumpsterDoggy

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <form name="form1" method="post" action="">
      <p>
        <label>
        <input type="radio" name="RadioGroup1" value="op1">
        Option1</label>
        <br>
        <label>
        <input type="radio" name="RadioGroup1" value="op2">
        Option2</label>
        <br>
        <label>
        <input type="radio" name="RadioGroup1" value="op3">
        Option3</label>
        <br>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form>
    <?php
    if(isset($_POST['RadioGroup1'])){
        switch(
    $_POST['RadioGroup1']){
            case 
    'op1':
                echo 
    'You chose Option1';
                break;
            case 
    'op2':
                echo 
    'You chose Option2';
                break;
            case 
    'op3':
                echo 
    'You chose option3';
                break;
        }
    }
    ?>


  •  

    Posting Permissions

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