View Full Version : Radio Button Actions (print based on selection)

04-27-2006, 10:56 PM
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!


04-28-2006, 12:15 AM
<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];

<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>


04-28-2006, 02:41 PM
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:

var optText = ["<!--#include virtual='business.php' -->", "<!--#include virtual='government.php' -->", "<!--#include virtual='business.php' -->"];

And I tried:

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.