Page 1 of 1
get the value from image button
Posted: Sat Mar 12, 2005 1:38 am
by valen53
The below 1 is image button. I want to get this button value.
But it not same with button that can get the value.
So any way can get the value from image button ?
<input name="Image1" value="Search" type="image" src="images/ql_ntu1.gif" >
Posted: Sat Mar 12, 2005 2:38 am
by feyd
you want php to get the "value" ? From what I remember, image inputs don't have a value per se, as they submit the x,y coordinates you clicked.
Posted: Sat Mar 12, 2005 7:12 am
by Ambush Commander
A button can only have one value, correct? Then you can determine which button was clicked by seeing which values (xy coords) are defined and which ones are not.
Posted: Sat Mar 12, 2005 7:16 am
by infolock
or couldn't you always set an action or onclick action? =P forcing it to run a js function that will report it had been clicked? works for me...
especially with the <button> operator since you can embed images within it and completely control the way it behaves as a button instead of the common <Input type="button"> where you are limited to what you can do...
Posted: Sat Mar 12, 2005 7:21 am
by Ambush Commander
Well, since JS is a client side langauge, there's no guarantee it will work. I think my way is the best:
Untested
Code: Select all
$form_buttonpairs['image1'] = "Search";
//Add extra values as needed
foreach($form_buttonpairs as $key => $value) {
if (isset($_POST[$key])) {
$_POST[$key] = $value;
}
}
You're allowed to overload $_POST values right?
Posted: Sat Mar 12, 2005 7:31 am
by infolock
not to try and argue, but there is most definately a way for it to work.. i use it all the time
i'm not gonna write the entire thing, but all it boils down to is doing a simple :
<button onclick=jsscript('myvaluetopass'); name="bob">
jsscript could then say document.location.replace('bob.php?value=$valuepassed')
php just does a $_GET['value'], boom bam splat, ye get what you needed...
Posted: Sat Mar 12, 2005 7:35 am
by Ambush Commander
Err... I'm not trying to say your solution 'wouldn't' work under most circumstances. I'm saying that you can't always expect "JavaScript" to be there for you. I'm pretty sure we can handle this entirely on the server side, so there's no need to introduce Client Side Scripting.
Posted: Sat Mar 12, 2005 7:40 am
by infolock
to each his own i guess
