Jump to content


Photo

Radio Buttom for beginner


  • Please log in to reply
6 replies to this topic

#1 j_prakash81

j_prakash81
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 01 September 2006 - 01:17 PM

Hello guyzzz  i'm realy new to PHP. Recently im train my self to code in php with simple radio button but it's not working. the idea....there is a two radio button in my page, when the user chose and click the submit button it should transfer to particuler page.....anybody can help me...

the code goes like this
<?

$choise;
$a = "a" ;

print
"<CENTER>
<table border='0' width='20%'>

<form method='POST' action=$choise.php>

<tr>
  <td colspan='2' >Selection</td>

</tr>
<tr>
  <td width='1%'><input type='radio' name='select' value='a' checked></td>
  <td>A to page A.php</td>
</tr>
<tr>
  <td><input type='radio' name='select' value='b'></td>
  <td>B to page B.php</td>
</tr>"

if ($a == select) {
$choise = $a;
print "<tr ALIGN='CENTER'>
<td colspan='2'><input type='submit' value='Submit' name='B1'></td>
</tr>"

else {
$choise = $b
print "<tr ALIGN='CENTER'>
<td colspan='2'><input type='submit' value='Submit' name='B1'></td>
</tr>"
}
print "<BR></form></table>";

?>

#2 chuddyuk

chuddyuk
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationEngland

Posted 01 September 2006 - 01:33 PM

Im A newb aswell but it looks like you aint set your variables up right

and the form is going to a page that dosnt exist because you havnt set $choise to anything, also your coding html in php wrong

for a line of html like wat you have there you need

echo"<td><input type=\'radio\' name=\'select\' value=\'b\'></td>";

think its best if you start again and look for examples on the net


#3 j_prakash81

j_prakash81
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 September 2006 - 02:05 AM

what is different between echo and print function..

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 02 September 2006 - 02:09 AM

what is different between echo and print function..


Nothing substantive. You can read all about both in the online manual if you're interested.
Legend has it that reading the manual never killed anyone.
My site

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 02 September 2006 - 03:24 AM

if you want the user to click on a radio button, hit submit, and it goes to the same page regardless, but does something based on which radio button was selected, then you would use php. if you want to select 'a' or 'b' radio button, and it takes you to a.php or b.php, you are going to have to do that with javascript.

php is a server side language. all php code is parsed on the server, before anything is sent to your computer.  so you cannot make 'on-the-fly' decisions like that with php.  javascript is a client side language.  you can make 'on-the-fly' decisions using their onfocus, onclick, onblah event handlers to change the action = 'blah.php' in your form. 

since your question looks like the 2nd of the 2, i'm moving this to javascript help.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#6 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 02 September 2006 - 04:45 AM

<form>
<input type="radio" onclick="javascript: window.location('a.php');">
</form>

Should work... I tend to avoid radio boxes and JS though so Im not sure...
Why doesn't anyone ever say hi, hey, or whad up world?

#7 j_prakash81

j_prakash81
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 September 2006 - 02:46 PM

thank's guys......
will keep in touch...... ;)

--------------
thammudu




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users