jaiffed Posted February 23, 2010 Share Posted February 23, 2010 I have this script <form name="memlook" method="post" action="memmodify.php"> <table width="277" border="0" align="center"> <tr> <td width="128"><input name="radio" type="radio" id="memid" value="memid" checked="checked" /> Member Id </td> <td width="139"><label> <input type="radio" name="radio" id="memname" value="memname" /> </label> Member Name</td> </tr> <tr> <td colspan="2"><input name="memdet" type="text" id="memdet" size="45" /></td> </tr> </table> <p> </p> <table width="62" border="0" align="center"> <tr> <td width="66"><input name="cmdsubmit" type="submit" id="cmdsubmit" value="Search" /></td> </tr> </table> now the problem is that i have two radio button as you see memid and memname now i want that if memid is selected an user press submit then memid.php file open and if user select memname and press submit then memname.php file open Link to comment https://forums.phpfreaks.com/topic/193108-radio-button-help/ Share on other sites More sharing options...
iPixel Posted February 23, 2010 Share Posted February 23, 2010 What you're looking for is javascript not PHP, in your form tag do onSubmit="functionname()" and in your javascript check what radio button is being passed and depending on that send to window.location. Enjoy! Link to comment https://forums.phpfreaks.com/topic/193108-radio-button-help/#findComment-1016954 Share on other sites More sharing options...
teamatomic Posted February 23, 2010 Share Posted February 23, 2010 in memmodify.php <?php $radio=$_POST['radio']; $memdet=$_POST['memdet']; if ($radio=='memname') { header("location: memname.php?memdet=$memdet") } else { header("location: memid.php?memdet=$memdet"); } HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/193108-radio-button-help/#findComment-1016971 Share on other sites More sharing options...
lovelyvik293 Posted February 23, 2010 Share Posted February 23, 2010 You can use this code if you want to select the desired page in javascript and html only <script type="text/javascript"> function login() { var loginForm = document.getElementById("memlook"); if (loginForm.memid.checked) { var submitForm = document.getElementById("memidForm"); submitForm.memdet.value = loginForm.memdet.value; submitForm.submit(); } if (loginForm.memname.checked) { var submitForm = document.getElementById("memnameForm"); submitForm.memdet.value = loginForm.memdet.value; submitForm.submit(); } } </script> <form id="memlook" method="post" action="#"> <table width="277" border="0" align="center"> <tr> <td width="128"><input name="memid" type="radio" id="memid" value="memid" checked="checked" /> Member Id </td> <td width="139"><label> <input type="radio" name="memname" id="memname" value="memname" /> </label> Member Name</td> </tr> <tr> <td colspan="2"><input name="memdet" type="text" id="memdet" size="45" /></td> </tr> </table> <p> </p> <table width="62" border="0" align="center"> <tr> <td width="66"> <input type="button" name="submit" value="Login" onclick="login();"/></td> </tr> </table> </form> <form action="memid.php" method="post" name="memidForm"> <input name="memdet" type="hidden" id="memdet" /> </form> <form action="memname.php" method="post" name="memnameForm"> <input name="memdet" type="hidden" id="memdet" /> </form> Link to comment https://forums.phpfreaks.com/topic/193108-radio-button-help/#findComment-1016981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.