Images as submit buttons
Moderator: General Moderators
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
Images as submit buttons
Hey guys, I have come across a particular problem that I can not find a solution for in google. I am wondering if someone may have some sample code for me.
My problem is that I have a form with multiple submit buttons. These are images that require mouseovers. I tried using type="image" in the input tags but I could not get mouseovers to work. I also tried using onclick="submit();" in an img tag but then I could not differentiate between the multiple submits.
I feel like I am banging my head against the wall. I know the solution must be simple and I would appreciate any help to get me pass this.
My problem is that I have a form with multiple submit buttons. These are images that require mouseovers. I tried using type="image" in the input tags but I could not get mouseovers to work. I also tried using onclick="submit();" in an img tag but then I could not differentiate between the multiple submits.
I feel like I am banging my head against the wall. I know the solution must be simple and I would appreciate any help to get me pass this.
You could...
Not sure this is "the" way tho... I flip the array, so note that you need to flip it once again to get the results as-is.
Code: Select all
<form method="post">
<input type="image" src="image.gif" name="a" value="Submit" />
<input type="image" src="image.gif" name="b" value="Submit" />
<input type="image" src="image.gif" name="c" value="Submit" />
</form>
<?php
if (!empty($_POST)) {
$newarray = array_flip($_POST);
echo $newarrayї'Submit'];
}
?>Code: Select all
<input onmouseover="this.src='dossier2.gif'" alt="Hover Button" onmouseout="this.src='dossier.gif'" type="image" src="dossier.gif" name="a" value="Submit" />Moving this thread to client side...
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
Just another question. I found I could not compare the name of the input to the value of the input. So doing
always fails. I found an article that stated the form only posts the x and y coordinates of the click. So doing
will perform the test. The article can be found here.
http://builder.com.com/5100-6371-5242116-3.html
Is this the best/only way to do this?
Code: Select all
$a = (isset($_POSTї'a'])?$_POSTї'a']:"");
if ($a == "Submit"){}Code: Select all
if ($_POSTї'a_x'] != ""){}http://builder.com.com/5100-6371-5242116-3.html
Is this the best/only way to do this?
...
Don't know in php but,
Have you tried in JavaScript to add the name(s) of the fields and pass them as a variable ( there are numerous ways ) so then php can process them.
For submit-ing I would do this:
And those little buttons: onClick="javascript:go_baby(parameter_A)"
Parameter A - action: page to where the form should be submitted.
ex. onClick="javascript:go_baby('process_page.php');"
Parameter A - use unique parameter for each button ( image ) and in that way the form will be submited where you want.
Hope this helps.
Have you tried in JavaScript to add the name(s) of the fields and pass them as a variable ( there are numerous ways ) so then php can process them.
For submit-ing I would do this:
Code: Select all
<script language="Javascript">
Function go_baby(a)
{
document.form_name.action = a;
document.form_name.submit();
}
</script>And those little buttons: onClick="javascript:go_baby(parameter_A)"
Parameter A - action: page to where the form should be submitted.
ex. onClick="javascript:go_baby('process_page.php');"
Parameter A - use unique parameter for each button ( image ) and in that way the form will be submited where you want.
Hope this helps.