By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,149 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Display php forms on click of radiobuttons

P: 63
Hi all. I have stuck up with a new problem.Hope anyone can find some solution for that.
I have three radiobuttons and the situation is that on click of each radio button a new php page is to be opened. I have done it using submit button. But actually it has to be done ON CLICK of the radiobuttons on not on SUBMIT.

The code i used for submit is given below. PLz help to customize this code so as to be helpful to satisfy the demanded situation

Thanks and Regards

[PHP]<form name="myForm" action="log_in.php" method="get">
<input type="radio" name="r" value="archilogin.php" selected="selected" onclick="this.form.action=this.value;"> Architects<br>
<input type="radio" name="r" value="conslogin.php" onclick="this.form.action=this.value;"> Consultants<br>
<input type="radio" name="r" value="varlogin.php" onclick="this.form.action=this.value;"> Others<br>
<input type="submit" value="Submit">
Feb 16 '08 #1
Share this Question
Share on Google+
4 Replies

P: 63
In addition to the code mentioned in my first post i have also made use of headers as the alternatite solution.But it also works on click of SUBMIT buttton and not just clicking the radiobutton. THe code is given below.Anyone kindly rescue me.

Thanks and Regards




if (isset($_POST['submit'])) {

$selected_radio = $_POST['login_page'];

if ($selected_radio == 'archi') {
else if ($selected_radio == 'consult') {

else if ($selected_radio == 'various') {



[HTML]<form name="form1" method="post" action="log.php">
<table width="194">
<tr><td><h1 class="articles">Members Login</h1></td>
<td width="114">

<input type="radio" name="login_page" value="archi">

<tr><td width="114">
<input type="radio" name="login_page" value="consult">

<tr><td width="114">
<input type="radio" name="login_page" value="various">
Others</td><td width="68"><input name="submit" type="submit" value=go></td>
Feb 16 '08 #2

Expert 2.5K+
P: 4,258
Use location.href to go to a new page, as follows:
<input type="radio" name="r" value="archilogin.php" selected="selected" onclick="location.href=this.value;"> Architects<br>
<input type="radio" name="r" value="conslogin.php" onclick="location.href=this.value;"> Consultants<br>
<input type="radio" name="r" value="varlogin.php" onclick="location.href=this.value;"> Others<br> [/html]
Feb 16 '08 #3

P: 63
Hey !!! Thanx Roverdonk.

You made my day. it was so simple.I will be back here on this forum to have some xtra tips if some othre problem exist s.Until then...bye.and great job [:)]

Thanx and Regards
Feb 18 '08 #4

Expert 2.5K+
P: 4,258
You are welcome. See you next time.

Feb 18 '08 #5

Post your reply

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