Good Morning Good People...

I have a question that I can't seem to find the answer to anywhere, so decided someone in here would know...

Simplest explanation...
I have a form which has 2 submit buttons... one to accept and one to decline
Each of them needs to set the same variable to different values.

I can do this easily by assigning the value in the input line, but this doesn't allow for me to use an image to click on, as opposed to a text link...

The question...
Is there a way to use an image for the link, and still assign a value to the name in the input line?

Any help or direction would be greatly appreciated.


What I tried to use was this:

<input type="image" name="subbed" src="../images/button_accept.png" width="113" height="34" border="0" alt="Accept Payment" value="a">

But assigning the value in that manner just doesn't accomplish the desired result


Here is what I have that works, without the image

<form name="<?php print $row_rq[12]; ?>" action="<?php print $_SERVER['PHP_SELF'];?>" method="POST">
<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="top" width="100" height="15"><b><font size="-1">Member Username</font></b><br><?php print $row_rq[12]; ?></td>
<td align="left" valign="top" width="250" height="15" rowspan="2">
<b><font size="-1">Contact Information</font></b><br><?php print $row_rq[4]; ?><br><?php print $row_rq[5]; ?>
<?php if ($row_rq[6]<>''){print "<br>".$row_rq[6];} ?>
<br><?php print $row_rq[7]; ?>, <?php print $row_rq[8]; ?> &nbsp;&nbsp;<?php print $row_rq[9]; ?><br><?php print $row_rq[10]; ?><br><?php print $row_rq[11]; ?>
</td>
<td align="center" valign="top" width="250" height="15"><b><font size="-1">Payout Amount</font></b><br><?php print $row_rq[2]; ?></td>

<td align="center" valign="middle" width="100" height="15">
<input type="submit" name="subbed" value="D">
</td>
</tr>

<input type=hidden name="user" value="<?php print $row_rq[12];?>" />
<input type="hidden" name="dest" value=<?php print $dest;?> />
<input type="hidden" name="wthd_id" value=<?php print $row_rq[0]; ?> />
<input type="hidden" name="amt_paid" value=<?php print $row_rq[2]; ?> />
<input type="hidden" name="mem_id" value=<?php print $row_rq[1]; ?> />
<input type="hidden" name="email" value=<?php print $row_rq[13]; ?> />
<input type="hidden" name="req_date" value=<?php print $row_rq[3]; ?> />
<input type="hidden" name="display" value=<?php print $display; ?> />
<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="top" width="100" height="15"><b><font size="-1">Date Requested</font></b><br><?php print $row_rq[3]; ?></td>

<td align="center" valign="middle" width="250" height="15"><b><font size="-1">Enter Transaction ID</font></b><br><input name="trans_id" type="text" size="20" maxlength="24"></td>
<td align="center" valign="middle" width="100" height="15">
<b><font size="-1">Net Paid</font></b><br><input name="net_pay" type="text" size="10" maxlength="10">
</td>
</tr>

<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="middle" width="100" height="15"><b><font size="-1">Note to Payee</font></b></td>
<td align="center" valign="top" width="500" height="15" colspan="2">
<textarea name="note" rows="2" cols="60"></textarea>
</td>
<td align="center" valign="middle" width="100" height="15">
<input type="submit" name="subbed" value="a">
</td>
</tr>
</form>

Recommended Answers

All 8 Replies

what you can do is set two image submits with diffrent variables
then test them once the form is submitted

<?php
if($_POST['formsubmit'] == "accept"){

// do some thing for accept    
    
}
if($_POST['formsubmit'] == "decline"){

// do some thing for decline   
    
}

?>
<form name="<?php print $row_rq[12]; ?>" action="<?php print $_SERVER['PHP_SELF'];?>" method="POST">
<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="top" width="100" height="15"><b><font size="-1">Member Username</font></b><br><?php print $row_rq[12]; ?></td>
<td align="left" valign="top" width="250" height="15" rowspan="2">
<b><font size="-1">Contact Information</font></b><br><?php print $row_rq[4]; ?><br><?php print $row_rq[5]; ?>
<?php if ($row_rq[6]<>''){print "<br>".$row_rq[6];} ?>
<br><?php print $row_rq[7]; ?>, <?php print $row_rq[8]; ?> &nbsp;&nbsp;<?php print $row_rq[9]; ?><br><?php print $row_rq[10]; ?><br><?php print $row_rq[11]; ?>
</td>
<td align="center" valign="top" width="250" height="15"><b><font size="-1">Payout Amount</font></b><br><?php print $row_rq[2]; ?></td>

<td align="center" valign="middle" width="100" height="15">
<input type="submit" name="subbed" value="D">
</td>
</tr>

<input type=hidden name="user" value="<?php print $row_rq[12];?>" />
<input type="hidden" name="dest" value=<?php print $dest;?> />
<input type="hidden" name="wthd_id" value=<?php print $row_rq[0]; ?> />
<input type="hidden" name="amt_paid" value=<?php print $row_rq[2]; ?> />
<input type="hidden" name="mem_id" value=<?php print $row_rq[1]; ?> />
<input type="hidden" name="email" value=<?php print $row_rq[13]; ?> />
<input type="hidden" name="req_date" value=<?php print $row_rq[3]; ?> />
<input type="hidden" name="display" value=<?php print $display; ?> />
<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="top" width="100" height="15"><b><font size="-1">Date Requested</font></b><br><?php print $row_rq[3]; ?></td>

<td align="center" valign="middle" width="250" height="15"><b><font size="-1">Enter Transaction ID</font></b><br><input name="trans_id" type="text" size="20" maxlength="24"></td>
<td align="center" valign="middle" width="100" height="15">
<b><font size="-1">Net Paid</font></b><br><input name="net_pay" type="text" size="10" maxlength="10">
</td>
</tr>

<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="middle" width="100" height="15"><b><font size="-1">Note to Payee</font></b></td>
<td align="center" valign="top" width="500" height="15" colspan="2">
<textarea name="note" rows="2" cols="60"></textarea>
</td>
<td align="center" valign="middle" width="100" height="15">
<input type="image" value="accept" src="acceptimage.gif" width="80" height="20" border="0" alt="SUBMIT!" name="formsubmit"> 
<input type="image" value="decline" src="declineimage.gif" width="80" height="20" border="0" alt="SUBMIT!" name="formsubmit"> 

</td>
</tr>
</form>

what you can do is set two image submits with diffrent variables
then test them once the form is submitted

<?php
if($_POST['formsubmit'] == "accept"){

// do some thing for accept    
    
}
if($_POST['formsubmit'] == "decline"){

// do some thing for decline   
    
}

?>
<form name="<?php print $row_rq[12]; ?>" action="<?php print $_SERVER['PHP_SELF'];?>" method="POST">
<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="top" width="100" height="15"><b><font size="-1">Member Username</font></b><br><?php print $row_rq[12]; ?></td>
<td align="left" valign="top" width="250" height="15" rowspan="2">
<b><font size="-1">Contact Information</font></b><br><?php print $row_rq[4]; ?><br><?php print $row_rq[5]; ?>
<?php if ($row_rq[6]<>''){print "<br>".$row_rq[6];} ?>
<br><?php print $row_rq[7]; ?>, <?php print $row_rq[8]; ?> &nbsp;&nbsp;<?php print $row_rq[9]; ?><br><?php print $row_rq[10]; ?><br><?php print $row_rq[11]; ?>
</td>
<td align="center" valign="top" width="250" height="15"><b><font size="-1">Payout Amount</font></b><br><?php print $row_rq[2]; ?></td>

<td align="center" valign="middle" width="100" height="15">
<input type="submit" name="subbed" value="D">
</td>
</tr>

<input type=hidden name="user" value="<?php print $row_rq[12];?>" />
<input type="hidden" name="dest" value=<?php print $dest;?> />
<input type="hidden" name="wthd_id" value=<?php print $row_rq[0]; ?> />
<input type="hidden" name="amt_paid" value=<?php print $row_rq[2]; ?> />
<input type="hidden" name="mem_id" value=<?php print $row_rq[1]; ?> />
<input type="hidden" name="email" value=<?php print $row_rq[13]; ?> />
<input type="hidden" name="req_date" value=<?php print $row_rq[3]; ?> />
<input type="hidden" name="display" value=<?php print $display; ?> />
<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="top" width="100" height="15"><b><font size="-1">Date Requested</font></b><br><?php print $row_rq[3]; ?></td>

<td align="center" valign="middle" width="250" height="15"><b><font size="-1">Enter Transaction ID</font></b><br><input name="trans_id" type="text" size="20" maxlength="24"></td>
<td align="center" valign="middle" width="100" height="15">
<b><font size="-1">Net Paid</font></b><br><input name="net_pay" type="text" size="10" maxlength="10">
</td>
</tr>

<tr bgcolor="<?php print $row_bg; ?>">
<td align="center" valign="middle" width="100" height="15"><b><font size="-1">Note to Payee</font></b></td>
<td align="center" valign="top" width="500" height="15" colspan="2">
<textarea name="note" rows="2" cols="60"></textarea>
</td>
<td align="center" valign="middle" width="100" height="15">
<input type="image" value="accept" src="acceptimage.gif" width="80" height="20" border="0" alt="SUBMIT!" name="formsubmit"> 
<input type="image" value="decline" src="declineimage.gif" width="80" height="20" border="0" alt="SUBMIT!" name="formsubmit"> 

</td>
</tr>
</form>

Unless I'm mistaken that is exactly the same as what I showed as having tried without success... Only difference was that my values were 'a' for accept and 'D' for decline...

For some reason, the 'Value' that was assigned to each submit Image, was not passed through.

look at like 2-11 thats diffrent and lines 52 and 53 i added two submitt buttons one is a image for accept and one to decline now once these buttons are hit the form is submitted both buttons are named forsubmit so now in hte begining you test
$_POST and if it is accept do what you need for accept and vice versa

begining you test $_POST and if it is accept do what you need for accept and vice versa

This would be the best way to do it.

look at like 2-11 thats diffrent and lines 52 and 53 i added two submitt buttons one is a image for accept and one to decline now once these buttons are hit the form is submitted both buttons are named forsubmit so now in hte begining you test
$_POST and if it is accept do what you need for accept and vice versa

Sorry for the delay in responding, but was dealing with other issues.

OK, I think what you are suggesting is exactly what I tried initially, but the 'VALUE' of the image type input statement doesn't seem to be passed as it is when just using a regular input...

I went back and replaced the regular inputs with the image inputs again and tested it, but it failed...

Exact same code for everything except the input statement... using the same values for the variable 'subbed' 'a' for accepted and 'D' for Declined...

if ( $_POST['subbed'] != 'y' && $_POST['subbed'] != 'a' && $_POST['subbed'] != 'D' ) {
// first time to the page, so display the form to select which payment processor

} elseif($subbed=='y') { // Submitted (selected pp withdrawals to process
  // payment processor selected, Now list all withdrawal requests using this processor. 
  // each request has an Accept request button  and a Decline Payment button
  // Admin can view all info relating to this withdrawal request 
  // and either Accept/Approve the request or Decline the request
  //  ONLY DIFFERENCE is that I replaced this input statement
<input type="submit" name="subbed" value="a"> 
  //  WITH THIS input statement
<input type="image" value="a" src="../images/button_accept.png" width="113" height="34" border="0" alt="Accept" name="subbed">
  // AND I replaced this input statement
<input type="submit" name="subbed" value="D">
  //  WITH THIS input statement
<input type="image" value="D" src="../images/button_decline.png" width="113" height="34" border="0" alt="Decline" name="subbed">


} elseif($subbed=='a') {   // subbed must be 'a'pproved, so make payment 
// if approved, payment is recorded in trans table and updates the request table
// payment is automatically made through online payment processor
// email is sent to the payee

} elseif($subbed=='D') {   // subbed must be 'D'eclined, so update recs
// if Declined, no trans record is created, but the request table record is updated with the new status and status date and email is sent to payee

}

With the regular input statements, it works perfectly, but with the image input statements it doesn't work at all

Any idea why???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.