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

    Cool Radio Button Actions (print based on selection)

    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 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 JavaScript hack and have tried NUMEROUS things to no availe. I really appreciate any help!

    THANKS!
    Kyle

  • #2
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    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
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is what I was looking for. Thanks! I do have one more question. Rather than writing text, I would like to include a file... I tried:

    Code:
    var optText = ["<!--#include virtual='business.php' -->", "<!--#include virtual='government.php' -->", "<!--#include virtual='business.php' -->"];
    And I tried:
    Code:
    var optText = ["<!--#include file='business.php' -->", "<!--#include file='government.php' -->", "<!--#include file='business.php' -->"];
    But that doesn't show anything when clicked. Is there any way to add that in? Will this even work? These includes are 4 (different) text boxes/drop down menus if that makes any difference.

    THANKS!
    Last edited by Kobescent; 04-28-2006 at 01:47 PM.


  •  

    Posting Permissions

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