Image submit button... sending values?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
sweahe
Forum Commoner
Posts: 52
Joined: Sat May 04, 2002 4:07 am
Location: Växjö, Sweden

Image submit button... sending values?

Post by sweahe »

I want a submit button that is an image and sends it value to my script, how can I do this?

This works in Mozilla:

Code: Select all

<input type="image" src="left.gif" name="submit" value="do_this" />
<input type="image" src="right.gif" name="submit" value="do_that" />
But as usual it doesn't work in IE6, the submit value is not sent!
How can I work around this? I would also prefer not to use Javascript, can I do it with CSS? Can i make a type="submit" button look like an image?

I guess I have the same problem as:
viewtopic.php?t=8286

/Andreas[/url]
sweahe
Forum Commoner
Posts: 52
Joined: Sat May 04, 2002 4:07 am
Location: Växjö, Sweden

Post by sweahe »

Think I found a solution, put the value in the name attribute instead:

Code: Select all

<?php

    if ($_POST['add_groups_x']) {
        echo 'add groups';
    }
    else if ($_POST['delete_groups_x']) {
        echo 'delete groups';
    }
?>
<html>
<head>
<title>Post test</title>
</head>
<body>
<form method="post" action="post.php">
<input type="image" src="images/left.gif" name="add_groups" />
<input type="image" src="images/right.gif" name="delete_groups" /> 
</form>
</body>
</html>
Post Reply