At 13:37 30.01.2003, Durwood Gafford spoke out and said:
--------------------[snip]--------------------
><input type="submit" name="sample" value="a" >
><input type="submit" name="sample" value="b" >
><input type="submit" name="sample" value="c" >
><input type="submit" name="sample" value="d" >
>
>your php form handler can now simply do:
>
>print "The user selected button $sample<br>\n")

This would display the "value" as button text. It works, BUT:
- you cannot divert content from data or functionality
- you have to modify code if you want to modify your page

Something that might not be worthwile, depends on the project size.

However, if you need to act on a button, you _need_ to test for something,
be it the name or the value.

>Although arrays might provide a solution that wouldn't quite be as good as
>the 'submit' button solution, but not as worse as a straight name-based
>'image' solution.

I still don't get it - maybe you could show us your approach to the
solution so we can grasp the problem?

>Given that the 'button' element with "type = submit" does NOT work, maybe
>the javascript solution is the most elegant. but i haven't gotten that to
>work yet either!

Now that's more easy:

<form name="myform">
<input type="hidden" name="button" value="">

... something here

<input type="image" src="img_1.gif"
    onClick="document.forms['myform']['button'].value='button_a'"><br>
<input type="image" src="img_2.gif"
    onClick="document.forms['myform']['button'].value='button_b'"><br>
<input type="image" src="img_3.gif"
    onClick="document.forms['myform']['button'].value='button_c'">
</form>

This will give you a $_REQUEST['button'] containing the button value. Note
though that this doesn't work if JS has been disabled in the browser, or if
the "browser" doesn't support JS at all.


-- 
   >O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
    ^ http://www.vogelsinger.at/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to