Forum Moderators: open

Message Too Old, No Replies

passing values through an image submitted form

input type=image

         

bennit

8:29 pm on Dec 14, 2007 (gmt 0)

10+ Year Member



My question is the folowing:
is there a way to pass the value of an image submit button that you give to it yourself, as the only thing IE passes is the xvalue and yvalue of where the user clicked the image.
I guess it's just a bug?

in mozilla this works fine but I'd prefer my site being fully compatible with all common browsers

If this helps you get an idea of what I want to achieve:
a guestbook that generates code for a smiley which u click.

this is my code so far (filename: new_msg.php)
...
<?
$image = $_POST['image'];
$msg = $_POST['msg'] . $image;
echo "<textarea type=text cols=63 rows=10 name=msg>$msg</textarea>";
?>
...
<input
type=image
src=msn/regular_smile.gif
action=new_msg.php
name=image
value="<img src=msn/regular_smile.gif>">
...

As I got several smiley's which are clickable I need several image-buttons, so I can't use a hidden input type.
I could use javascripts, if I would have aquired that knowledge yet, which i haven't :p

Anyone got a hint on how to solve this?

coopster

10:11 pm on Dec 14, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, bennit.

MS IE has behaved like that for years. You are best off just using the name to do your server side editing. The value of the <input> name attribute is what you will want to review. For example, if the html looks like this ...


<input type="image" name="regular_smile" src="regular_smile.gif" />
<input type="image" name="happy_smile" src="happy_smile.gif" />

Then in your PHP you would check for it like this ...
if (isset($_POST['regular_smile_x'])) { 
// I know the regular smile was clicked
}