Kappa Computer Solutions, LLC

Leveraging UNIX, GNU/Linux, open source, and
custom software solutions for business and beyond

Phone: 877•367•8837   Twitter: kappacs

Home arrow Articles arrow FormRequest: Dynamic Form Parameters
FormRequest: Dynamic Form Parameters PDF Print E-mail
Article Index
FormRequest: Dynamic Form Parameters
Page 2
Page 3

The Problem

Sometimes you want a particular form on a page to return different parameters or values depending on which button or javascript function is used to submit the form.

Here is a simple example:

<input type='submit' name='action' value='Stop' />
<input type='submit' name='action' value='Start' />

Whichever submit button is pressed is considered "active", and only its parameter and value are passed in the request ("action=Stop" or "action=Start").

If you want a graphic button instead of a text button, the example changes to something like this:

<button type='submit' name='action' value='Stop'>
<img src='stop.png' height='40' width='40' alt='Stop' /></button>
<button type='submit' name='action' value='Start'>
<img src='start.png' height='40' width='40' alt='Start' /></button>

This should work the same way as the textual submit buttons, and in some browsers it does. Unfortunately, some versions/document compatibility modes of Internet Explorer use the innerText of the button as its value, while IE6 considers all graphical submit buttons to be active, not just the one that was pressed (if any). Either way, it is likely that you will end up with an inappropriate request to the server.



 
Next >