...

View Full Version : Submit based on radio button selection



Harry
07-13-2003, 12:03 AM
I have a page where I want to submit to a different page
based on a selection of radio buttons. I have written the
following script but it always goes to 'ps_page_2.php' even
if I select the radio button with a value of '4'. Can
someone please help me on this. I'm new to JS and I would
appreciate all the help I can get

Thank you

Harry

<head>
<script language="javascript1.2" type="text/javascript">
function send_form()
{
if(document.ps.a_type.value != '4')
{
document.ps.action='ps_page_2.php';
}

if(document.ps.a_type.value == '4')
{
document.ps.action='ps_send_mail.php';
}

return true;
}
</script>
</head>

<form name="ps" action="what_page.php" method="post"
onsubmit="return send_form()">


<table align="center" width="70%" background="5.jpg">
<tr>
<td align="left"><input type="radio" name="a_type" value="1" checked></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>New Access:</font></td>
</tr>

<tr>
<td align="left"><input type="radio" name="a_type" value="2"></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>Change Existing Access:</font></td>
</tr>

<tr>
<td align="left"><input type="radio" name="a_type" value="3"></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>Delete Some Access:</font></td>
</tr>

<tr>
<td align="left"><input type="radio" name="a_type" value="4"></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>Delete All Access:</font></td>
</tr>

</table

Mr J
07-14-2003, 12:21 AM
Please try the following



<script language="javascript1.2" type="text/javascript">
function send_form(val){
if(val != '4'){
document.ps.action='ps_page_2.php';
document.ps.submit()
}

if(val == '4'){
document.ps.action='ps_send_mail.php'
document.ps.submit()
}

return true;
}
</script>


<form name="ps" action="what_page.php" method="post">


<table align="center" width="70%" background="5.jpg">
<tr>
<td align="left"><input type="radio" name="a_type" value="1" onclick="send_form(this.value)"></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>New Access:</font></td>
</tr>

<tr>
<td align="left"><input type="radio" name="a_type" value="2" onclick="send_form(this.value)"></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>Change Existing Access:</font></td>
</tr>

<tr>
<td align="left"><input type="radio" name="a_type" value="3" onclick="send_form(this.value)"></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>Delete Some Access:</font></td>
</tr>

<tr>
<td align="left"><input type="radio" name="a_type" value="4" onclick="send_form(this.value)"></td>
<td align="left"><font size="4" face="arial" color="#ffffff"><strong>Delete All Access:</font></td>
</tr>

</table>

</form>

Harry
07-14-2003, 04:57 AM
Thanks alot for that one. I really appreciate it. Just what I needed



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum