...

View Full Version : explicitly post a data



jacky_cheecheo
02-12-2004, 06:43 PM
my situation is like this:

<form action="test.php" method=post>
<input type=text name=txtTo>
<input type=text name=txtMessage>
<input type=button name=btnSend1 value=Send>
<input type=button name=btnSendAll value="Send to All">
</form>

i know how to make a button call a javascript function to submit the form...but i want to make those to buttons to be able to do that but with a different effect...

if the user click on the btnSend1 button, it will send the datas to test.php like normal. When btnSendAll is click, it will send to test.php with an extra data to let the system know that the user click btnSendAll instead of btnSend...

How can i do that, is there a way for me to post an extra data when the data is not from the <form>'s tag???

Do you all understand? What i'm typing here is kinda messy, isnt it?

hehe....thanks in advance though...

glenngv
02-13-2004, 03:05 AM
Make the buttons submit buttons so that the value of the clicked button is also part of the form data and sent to the server.

<input type="submit" name="btnSend1" value="Send">
<input type="submit" name="btnSendAll" value="Send to All">

jacky_cheecheo
02-13-2004, 10:53 PM
so how do i check which button has been click using php?

Garadon
02-13-2004, 11:07 PM
<?
if(!isset($btnSend))
{
?>
<form name=form1 action="test.php" method=post>
<input type=text name=txtTo>
<input type=text name=txtMessage>
<input type=button name=btnSend value=Send>
<input type=button name=btnSend value="Send to All">
</form>
<?
}else
{
switch($btnSend )
{
case 'Send':
{

break;
}
case 'Send to All':
{

break;
}
}
}

?>

jacky_cheecheo
02-13-2004, 11:23 PM
got it, thanks a thousand man...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum