?
Solved

PHP radio buttons problem

Posted on 2008-02-06
4
Medium Priority
?
298 Views
Last Modified: 2010-04-21
Hi all,

I have a problem with this script whereby when the continue button is pressed the page visually scans through the radio buttons options and rests on the last option always before going onto the next screen. This can be confusing for users if they selected option a and it looks like they have selected option c.

See this page for visual :

http://www.whatyouseeyoucannotbe.com/inves/freewill/tester.php

I know the php code at the top checks to see what option is selected and sends the user to the appropiate page but I don't want the user to see this scan visually.

Thanks,

D
<?php 
if(isset($_POST['go'])){
$pagetogo = $_POST['radio'];
if($pagetogo == 1){
header("Location: fwq.php");
exit;
}
if($pagetogo == 2){
header("Location: page2.php");
exit;
}
if($pagetogo == 3){
header("Location: fwz.php");
exit;
}
}
?>
 
<form id="form1" name="form1" method="post" action="">
  <label>
  <input type="radio" name="radio" id="radio" value="1" />
  </label> 
  Yes <br />
  <label>
  <input type="radio" name="radio" id="radio2" value="2" />
  </label>
  Some<br />
  <label> 
  <input name="radio" type="radio" id="radio3" value="3">
   No,<br>
  <br>
  <br>
  <input type="submit" name="go" id="submit" value="Continue" />
</label>
</form>

Open in new window

0
Comment
Question by:jones_bones
  • 2
4 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 20835391
>>the page visually scans through the radio buttons options and rests on the last option always
You will be happy to know that I don't see this behaviour on IE6 WinXP. Must be a browser issue. What I see is that whatever I clicked remains clicked until redirected.
BTW: Choosing Maybe takes me to  page not found
0
 

Author Comment

by:jones_bones
ID: 20835450
Okay thanks,

Yup I only set that one up as a test page. Yes, I've checked it now in IE alright and it works fine just not in FF. Same old story I guess :) Don't know, is there much I can do about it or can anyone think of a different way to arrange the code so that this problem does not occur?

Thanks,

D
0
 
LVL 7

Accepted Solution

by:
shirazti earned 2000 total points
ID: 20845289
Try this one.. Works fine with Both IE and FF 2.0

Please use the label tag properly... ;-)
<form id="form1" name="form1" method="post" action="">
     <input type="radio" name="radio" id="radio1" value="1" />
    		<label for="radio1">Yes</label>   
    		<br />
     <input type="radio" name="radio" id="radio2" value="2" />
    		<label for="radio2">Some</label>
     		<br />
      <input name="radio" type="radio" id="radio3" value="3">
       		<label for="radio3"> No</label>,<br>
      		<br>
      		<br>
      <input type="submit" name="go" id="submit" value="Continue"  />
 
</form>

Open in new window

0
 

Author Closing Comment

by:jones_bones
ID: 31428613
Excellent! Thanks for spotting that!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question