Jump to content

Radio Button Help


jaiffed

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.