Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2003
    Location
    Houston, Texas
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Submit based on radio button selection

    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
    Beyond a critical point within a finite space, freedom diminishes as numbers increase. ...The human question is not how many can possibly survive within the system, but what kind of existence is possible for those who do survive."

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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>


  • #3
    New Coder
    Join Date
    Jul 2003
    Location
    Houston, Texas
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks alot for that one. I really appreciate it. Just what I needed
    Beyond a critical point within a finite space, freedom diminishes as numbers increase. ...The human question is not how many can possibly survive within the system, but what kind of existence is possible for those who do survive."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •