j_prakash81 Posted September 1, 2006 Share Posted September 1, 2006 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<?[color=green]$choise;$a = "a" ;[/color]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>"[color=green]if ($a == select) {$choise = $a;[/color]print "<tr ALIGN='CENTER'><td colspan='2'><input type='submit' value='Submit' name='B1'></td></tr>"[color=green]else {$choise = $b[/color]print "<tr ALIGN='CENTER'><td colspan='2'><input type='submit' value='Submit' name='B1'></td></tr>"}print "<BR></form></table>";?> Quote Link to comment Share on other sites More sharing options...
chuddyuk Posted September 1, 2006 Share Posted September 1, 2006 Im A newb aswell but it looks like you aint set your variables up rightand the form is going to a page that dosnt exist because you havnt set $choise to anything, also your coding html in php wrongfor a line of html like wat you have there you needecho"<td><input type=\'radio\' name=\'select\' value=\'b\'></td>";think its best if you start again and look for examples on the net Quote Link to comment Share on other sites More sharing options...
j_prakash81 Posted September 2, 2006 Author Share Posted September 2, 2006 what is different between [color=blue]echo[/color] and [color=blue]print[/color] function.. Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 2, 2006 Share Posted September 2, 2006 [quote author=j_prakash81 link=topic=106494.msg426345#msg426345 date=1157162754]what is different between [color=blue]echo[/color] and [color=blue]print[/color] function..[/quote]Nothing substantive. You can read all about both in the online manual if you're interested. Quote Link to comment Share on other sites More sharing options...
.josh Posted September 2, 2006 Share Posted September 2, 2006 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. Quote Link to comment Share on other sites More sharing options...
corbin Posted September 2, 2006 Share Posted September 2, 2006 <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... Quote Link to comment Share on other sites More sharing options...
j_prakash81 Posted September 2, 2006 Author Share Posted September 2, 2006 thank's guys......will keep in touch...... ;)--------------thammudu Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.