Jump to content

[SOLVED] Multiple Submit Buttons One Form


dlebowski

Recommended Posts

I need someone to help me with this.  As you can see below, I have "UPDATE LOT" form button at the bottom.  When clicked it opens a new window and takes me to addeditlotsupdate.php exactly the way I want it to.  Next to that is a "DELETE LOT" button.  I don't want it to submit the values to addeditlotsupdate.php.  Instead I want it to submit the values to deletelot.php.  Can anyone tell me how to do that?  Any help would be appreciated.  Thanks!

 

<form action="<? echo "addeditlotsupdate.php" ?>" ONSUBMIT="openTarget(this, 'width=1000,height=450,resizable=1,scrollbars=1'); return true;" target="newpopup" method="POST">
<tr>
<? echo "<input type='hidden' name='ud_LotID' value='$LotID'>";?>
<? echo "<input type='hidden' name='ud_LotPaymentExempt' value='$LotPaymentExempt'>";?>
<? echo "<input type='hidden' name='ud_LotDescription' value='$LotDescription'>";?>
<TD><? echo "<input type='text' size='5' name='ud_LotNumber' style='background-color:$color; text-align:center; border-style: solid; border:1px solid #0069af' value='$LotNumber'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='46' name='ud_LotTitle' style='background-color:$color; border:1px solid #0069af' value='$LotTitle'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='9' name='ud_SellingPrice' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$SellingPrice'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='5' name='ud_LotQuantity' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$LotQuantity'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='7' name='ud_Buyer' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$Buyer'>";?></td>
<TD width="1"></td>
<TD><? echo "<select style='background-color:$color; border:1px solid #0069af;' name='ud_OnlineOnsite'>"; ?><option value="ONLINE" <? if ($OnlineOnsite == "ONLINE") echo "selected"; ?> >ONLINE</option><option value="ONSITE" <? if ($OnlineOnsite == "ONSITE") echo "selected"; ?> >ONSITE</option></select></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='9' name='ud_AbsenteeBid' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$AbsenteeBid'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='7' name='ud_SellerNumber' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$SellerNumber'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='10' name='SelectLotAuctionDate' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$LotAuctionDate'>";?></td>
<TD width="1"></td>
<td><input style="font-size: 9px; height: 20px;" type="submit" value ="Update" alt="UPDATE LOT"><input style="color: red; font-size: 9px; height: 20px;" type="submit" value ="Delete" name="submit2" alt="DELETE LOT"></td>
</tr>
<tr><TD width="1"></tr>
</form>

Link to comment
Share on other sites

try this:

 

<script language="javascript">
function deleteIt()
{
document.uf.action="deletelot.php";
document.uf.submit();
}
function addIt()
{
document.uf.action="addeditlotsupdate.php";
document.uf.submit();
}
</script>



<form name="uf" action="<? echo "addeditlotsupdate.php" ?>" ONSUBMIT="openTarget(this, 'width=1000,height=450,resizable=1,scrollbars=1'); return true;" target="newpopup" method="POST">
<tr>
<? echo "<input type='hidden' name='ud_LotID' value='$LotID'>";?>
<? echo "<input type='hidden' name='ud_LotPaymentExempt' value='$LotPaymentExempt'>";?>
<? echo "<input type='hidden' name='ud_LotDescription' value='$LotDescription'>";?>
<TD><? echo "<input type='text' size='5' name='ud_LotNumber' style='background-color:$color; text-align:center; border-style: solid; border:1px solid #0069af' value='$LotNumber'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='46' name='ud_LotTitle' style='background-color:$color; border:1px solid #0069af' value='$LotTitle'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='9' name='ud_SellingPrice' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$SellingPrice'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='5' name='ud_LotQuantity' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$LotQuantity'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='7' name='ud_Buyer' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$Buyer'>";?></td>
<TD width="1"></td>
<TD><? echo "<select style='background-color:$color; border:1px solid #0069af;' name='ud_OnlineOnsite'>"; ?><option value="ONLINE" <? if ($OnlineOnsite == "ONLINE") echo "selected"; ?> >ONLINE</option><option value="ONSITE" <? if ($OnlineOnsite == "ONSITE") echo "selected"; ?> >ONSITE</option></select></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='9' name='ud_AbsenteeBid' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$AbsenteeBid'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='7' name='ud_SellerNumber' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$SellerNumber'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='10' name='SelectLotAuctionDate' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$LotAuctionDate'>";?></td>
<TD width="1"></td>
<td><input style="font-size: 9px; height: 20px;" type="button" value ="Update" alt="UPDATE LOT" onclick="addIt()"><input style="color: red; font-size: 9px; height: 20px;" type="button" value ="Delete" name="submit2" alt="DELETE LOT" onclick="deleteIt()"></td>
</tr>
<tr><TD width="1"></tr>
</form>

Link to comment
Share on other sites

Thanks for the reply.  I think I'm on the right track now.  But here is what I need to have happen.  When they click on "Update Lot" I need it to pop open a window and go to "addeditlotsupdate.php".  It works perfectly.  The "DELETE LOT" is the one I need to tweak.  The "deletelot.php" is actually the page the form is coded in.  So all I need it to do is just submit the form information back to the same page.  Does that make sense?  So there should be no pop up window for it.  It just just submit the form data to the existing page and then the existing page is coded to know how to do the delete.  Thanks again for you help.  Any suggestions on how to accommodate this would be greatly appreciated!

 

Ryan

Link to comment
Share on other sites

if your only using one php page with this add/delete code in it; then you do not need two different pages. you need to set up 2 variables in your php page - similar to this:

 

<?php

$action = $_GET['action'];

if ($action == "add") {
// add code here
exit;
}
else if ($action == "delete") {
// delete code here
exit;
}
else {
header("Location: ". $_SERVER['HTTP_REFERER'] ."");
exit;
}

?>

 

then, do this in your html page:

 

<script language="javascript">
function deleteIt()
{
document.uf.action="addeditlotsupdate.php?action=delete";
document.uf.submit();
}
function addIt()
{
document.uf.action="addeditlotsupdate.php?action=add";
document.uf.submit();
}
</script>



<form name="uf" method="POST">
<tr>
<? echo "<input type='hidden' name='ud_LotID' value='$LotID'>";?>
<? echo "<input type='hidden' name='ud_LotPaymentExempt' value='$LotPaymentExempt'>";?>
<? echo "<input type='hidden' name='ud_LotDescription' value='$LotDescription'>";?>
<TD><? echo "<input type='text' size='5' name='ud_LotNumber' style='background-color:$color; text-align:center; border-style: solid; border:1px solid #0069af' value='$LotNumber'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='46' name='ud_LotTitle' style='background-color:$color; border:1px solid #0069af' value='$LotTitle'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='9' name='ud_SellingPrice' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$SellingPrice'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='5' name='ud_LotQuantity' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$LotQuantity'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='7' name='ud_Buyer' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$Buyer'>";?></td>
<TD width="1"></td>
<TD><? echo "<select style='background-color:$color; border:1px solid #0069af;' name='ud_OnlineOnsite'>"; ?><option value="ONLINE" <? if ($OnlineOnsite == "ONLINE") echo "selected"; ?> >ONLINE</option><option value="ONSITE" <? if ($OnlineOnsite == "ONSITE") echo "selected"; ?> >ONSITE</option></select></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='9' name='ud_AbsenteeBid' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$AbsenteeBid'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='7' name='ud_SellerNumber' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$SellerNumber'>";?></td>
<TD width="1"></td>
<TD><? echo "<input type='text' size='10' name='SelectLotAuctionDate' style='background-color:$color; border:1px solid #0069af; text-align:center' value='$LotAuctionDate'>";?></td>
<TD width="1"></td>
<td><input style="font-size: 9px; height: 20px;" type="button" value ="Update" alt="UPDATE LOT" onclick="addIt()"><input style="color: red; font-size: 9px; height: 20px;" type="button" value ="Delete" name="submit2" alt="DELETE LOT" onclick="deleteIt()"></td>
</tr>
<tr><TD width="1"></tr>
</form>

 

also, I removed the onsubmit event from your form; it is what was creating the pop-up window that you said you did not want.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.