What is the standard way to provide a set of different options available for clicks, all of which represent the same form?

I have a page with PHP that displays some data about a set of movies. The page is refreshed using POST. The form displays only movies starting with a specific letter. I want to present a set of interactive options at the top of the screen, each of which is a letter. So if you hit "B" it will submit the form and re-draw the page showing only movies that start with B. (I know Ajax would be the best way to do this, but I'm trying to do something quickly).

Anyway, I know I can do this if each link is a Javascript call that sets the value of a hidden field and then submits the form, or I could do it by having each letter that has a specific meaning and submits the form directly but none of them strike me as particularly elegant. Is there a standard way to do this? Am I missing something really obvious?

0


source to share


5 answers


You can always create multiple submit buttons and give each a different name. Then you test to see which request was clicked, depending on what's included in the POST array.



Note that instead of the input type, enter the image input type so that you can replace your own image, etc. for your button.

+4


source


I think you are pretty much covering the options that you have. I usually see this with javascript and hrefs because people don't like to create real buttons.



+1


source


Remember that Internet Explorer (6/7?) Does not POST the variable with the button name to <input type = "image"> - it only sends variables with name_x and name_y with the coordinates of where the button was clicked.

+1


source


You don't actually need to submit the form as you are not using it.

Why not just a bunch of hyperlinks B

0


source


Use several different submit buttons, for example:

<input type="submit" name="letter" value="A" />
<input type="submit" name="letter" value="B" />
<input type="submit" name="letter" value="C" />
...

      

0


source







All Articles