Forum Moderators: open

Message Too Old, No Replies

Can the form action change depending on a user selection?

Form actions question

         

ipfreely1892

8:58 pm on May 24, 2003 (gmt 0)

10+ Year Member



Is it possible to have more than one url in a form, if the target url is dependent on the selection made

For example, if your users are selecting and submitting only one item from a list of radio inputs, say 1-5 , but the items aren't submitted to a common url specified as the action. Items 1,2 and 3 have target url [1...] and items 4 and 5 have target url [2....]

Is there a way around this without using more than 1 form?

bonanza

10:38 pm on May 24, 2003 (gmt 0)



This cannot be done with standard HTML, but you can accomplish this with some basic form-handling Javascript.

Use an onSubmit event on the form. In that function, check the form values to decide which URL you want to submit to.

ricfink

10:48 pm on May 24, 2003 (gmt 0)

10+ Year Member



Yeah, changing the action URL on the form element using Javascript.
First, the javascript function would detect which radio buttons were selected and then change the target url accordingly.

However, I'm a little fuzzy on exactly what's going on here.
Usually, radio buttons are used when the user is making a choice of one thing out of several.

How is this being done with two forms and three radio buttons in one and two in the other?
Is the user prevented in any way from making a selection in both?

ipfreely1892

12:10 am on May 25, 2003 (gmt 0)

10+ Year Member



ty for your help. :)