Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

changing submit value with radio buttons

Options
  • 07-12-2004 6:20pm
    #1
    Registered Users Posts: 483 ✭✭


    hi,
    im writing a web page and i have 4 radio buttons and dependin on which one is selected i want to change where the submit button takes the user! ie
    if view is selected i want to be brought to view.asp
    if update is selected i want to be taken to update.asp
    if add is selected i want to ba taken to add.asp
    and if delete is selected i want to ba taken to delete.asp

    has any one any ideas?

    thanks,
    Richie


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Either give them the same names as the pages, or work by values.


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Redirects will be your friend.

    Either where the page is submitted, or by javascript.

    The button has a onClick() function defined (or the form has an onSubmit() function defined). When the user clicks the button, the Javascript detects which radio button is selected, then uses window.location() to change the current page to the one you want.

    Alternatively, if you have PHP or something, you can submit the form to a simple php page, which calls location() depending on which radio button was selected.


  • Registered Users Posts: 483 ✭✭banbutcher


    shít sorry i got it wrong!, when the submit button is pressed the action of the form is value i want changed?


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Aha.

    OK, so if someone chooses View, you want to go to view.asp, and that script uses the variables from the form for its own purposes?

    Same still applies really.

    Afaik, the method will have to be "GET", but I'm not 100% on that. Basically, when the submit button is pressed, use the Javascript to generate the GET line, and then add it into the window.location() function.

    So instead of just calling
    window.location("view.asp")
    you call
    window.location("./view.asp?var1=a&var2=b&var3=c")
    Etc.

    Can be substituted with a PHP script that does the same thing (although you will be able to POST the data in that case).


Advertisement