Reputation: 855
I have a form displaying a resource with several fields. The form is rendered inside the resources index page. On the form there are some radio buttons for selecting resource types. When a radio button is selected, I would like the form to be submitted and reloaded, as the form is displayed differently according to which resource type is selected. When the submit button is pressed, I would like the form to be replaced by something else.
I have a function that fires when the form is submitted, but I don't know how I can make it do one thing when the form is submitted by a radio button, and another thing when it is fired by the submit button.
How can I do this?
Upvotes: 3
Views: 98
Reputation: 32081
For the first question, why not store a special value in an <input type="hidden"> or a global variable in your 'select' handler right before you submit the form?
Then in your submit handler you could check to see if it's set -- this will tell you whether the submit was triggered from the radio button or in another way.
Upvotes: 1