473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to get the value of this radio button

I have a test.php file that contains a set of radio buttons generated inside a loop. then I append the $i variable to the radio button name to have a unique set of radio buttons.
the scenario should be this: when i click the submit button, test2.php should display the values of the radio buttons selected in the test.php file

FILE: test.php

<html>
<head>
<title>RADIO</title>
</head>
<body>
<form method="post" action="test2.php">
<table align="center" border="1" width="40%">
<input type="text" name="name">
<?php
if($_POST['sub']){
$rad = $_POST['radio'.$i];
$name = $_POST['name'];
}
for($i=1; $i<=3; $i++){
echo "<tr>
<td align='left'><b>Question number: $i</b><br>
<input type='radio' name=radio.$i value='$i'>
</td>
</tr>

<tr>
<td align='left'>
<input type='radio' name=radio.$i value='$i'>
</td>
</tr>
<tr>
<td align='left'>
<input type='radio' name=radio.$i value='$i'>
</td>
</tr>
<tr>
<td align='left'>
<input type='radio' name=radio.$i value='$i'>
</td>
</tr>";
}
echo '</table>';
?>
<input type="submit" name="sub" value="go">
</form>
</body>
</html>



FILE: test2.php

<?php
$name = $_POST['name'];
$rad = $_POST['radio'.$i];
echo $name;
echo '<br>';
echo $rad;
?>
Feb 5 '08 #1
3 2841
Markus
6,050 Expert 4TB
Don't double post stuff.
And use code tags.
Feb 5 '08 #2
Don't double post stuff.
And use code tags.

I'm sorry but i dont get your point.
Feb 6 '08 #3
Markus
6,050 Expert 4TB
I'm saying you already have a thread on this.
So don't start a new one.
Feb 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Randell D. | last post by:
Folks, I have a form (called FORM1) - In my INPUT submit tag, I have an onClick event that I have successfully tested/used to display the value of a TEXT box using the following function (called...
13
by: Clevo | last post by:
Hello, I want to check if user select one from the radiobox group. How can I get the radiobox actual value in javascript. In the value field I see the default value, but how can I know if it...
2
by: jason | last post by:
The following (likely far from imperfect code), reports a value of NaN in the j4 display. I suppose the problem is I am not really passing the "checked" value of the radio button via .value ......
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
3
by: MarsVoyager | last post by:
Hi, I want to change the value of a submit button when the onChange event is fired by a Radio Input. Problem is, it seems the value is modified in the gui only when the Radio Input looses focus,...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
2
by: Stoic | last post by:
I'm offering a selection of three items. One is $25, the second is $50, the third is $100. Along with selection one of the items I need to pass the quantity of the selection. Here is the code now....
2
by: darrel | last post by:
I'm using some standard HTML radio buttons (to allow finer javascript interaction) on a web page and would like to catch the selected item on postback. Since they are all ID's uniquely, is there a...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.