...

View Full Version : Radio Button Print Code



Kobescent
04-27-2006, 11:03 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 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

PremiumBlend
04-28-2006, 12:14 AM
Is this what you're looking for?

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

degsy
04-28-2006, 02:56 PM
<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;
}
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum