[Javascript] selecting between multiple submit buttons

Scott Reynen scott at randomchaos.com
Wed Jul 25 10:06:12 CDT 2007


On Jul 22, 2007, at 7:37 AM, jm wrote:

> i have a form that uses multiple submit buttons: one to select from a
> dropdown list of menu options, one to add a new record or update an
> existing record depending on which is appropriate at the time, and one
> to delete an existing record.

Do you have a URL for this so we can all see it?  My first  
inclination would be to put separate functionality in separate  
forms.  If they're so inter-related that separate forms isn't  
possible, I'd determine the core functionality and put that in your  
HTML, then add the additional JavaScript-required elements via  
JavaScript so that visitors without JavaScript don't get a broken  
form.  I would also use non-submit buttons wherever the submission  
process is entirely mediated by JavaScript.  If you really need  
separate triggers for each button, I'd attach separate onclick  
handlers to each button rather than attaching an onsubmit handler to  
the whole form.

Peace,
Scott



More information about the Javascript mailing list