Link to home
Start Free TrialLog in
Avatar of rivkamak
rivkamakFlag for United States of America

asked on

force form submit() specify button

I have a function onclick an image.
At the end of the function I want the page form to submit
document.form1.submit();

Can I specify another parameter on the submit? I want to pretend that someone clicks the real submit button.
My asp page is looking for submit = "" or not. How can I make that not blank?
Avatar of leakim971
leakim971
Flag of Guadeloupe image

<form onsubmit="return false;">
And onclick of your image button :
OnClick="document.forms[0].onsubmit=null"
<form onsubmit="return false;">
And onclick of your image button :
OnClick="document.forms[0].onsubmit=null;document.forms[0].submit()"
Instead of inlining your JavaScript, create a function to do the submittal and forget form onsubmit="return false; altogether.
Avatar of rivkamak

ASKER

Let me show you my code:

this is the function I run onclick of the button:
<Script>
function deleteFun(num) {
document.form1["newAmount" + num].value = 0;
document.form1.submit();
}
</script>

Open in new window


But then I need ASP code to run. This code runs if a different button on the page is clicked.
IF Request( "input" ) = "Keep Shopping" THEN
response.redirect("donors_page_open.asp")
end if 

Open in new window


How can I get the form to fake that the input button "keep shopping" was really selected?
Pass a parameter to the ASP page, either in a hidden text field or in the URL.
Let me rephrase the question. Here is my code.
 It's a shopping cart. Based on what they click it will bring them back shopping or checkout. I need to somehow have a delete item next to each item. I need to be able to keep track on which item they want to delete. I thought to use a onclick feature. But then the page doesn't update properly

How else can I make a button or image per item to delete only that id?

<form id="form1" name="form1" method="get" action="cart.asp">
          <table width="599" border="0" cellpadding="0" cellspacing="0" >
            <tr bgcolor="#f0f0f0" >
              <td width="13" height="24" valign="top">&nbsp;</td>
              <td width="121" valign="top"><strong>Product</strong></td>
              <td width="49" valign="top"><strong>Price</strong></td>
              <td width="98" valign="top"><strong>Quantity</strong></td>
              <td width="159" valign="top"><strong>Cost</strong></td>
              <td width="159" valign="top">&nbsp;</td>
              </tr>
            <% 
'FOR i = 1 TO 46

For Each key In Request.Cookies("itemID")
i = CStr(key)
IF request.cookies("itemAmount")(i) <> "" THEN
IF request.cookies("itemAmount")(i) > 0 THEN

%>
            <tr bgcolor="#d9f5fa">
              <td valign="top">&nbsp;</td>
              <td valign="top" class="cartPrizes"><%=request.cookies("itemName")(i)%></td>
              <td valign="top" class="remove">$<%=request.cookies("itemCost")(i)%></td>
              <td valign="bottom" class="remove"><input name="newAmount<%=i%>" type="text" id="newAmount<%=i%>" value="<%=request.Cookies("itemAmount")(i)%>" size="4" /></td>
              <td valign="bottom" class="remove">$<%=(request.cookies("itemCost")(i)*request.Cookies("itemAmount")(i))%></td>
              <td valign="bottom" class="remove"><!-- <input type="button" name="delete" id="delete" value="Delete" onclick="deleteFun(<%'=i%>);" /> --></td>
              </tr>
            <% 
END IF
costItem=(request.cookies("itemCost")(i)*request.Cookies("itemAmount")(i))
totalCost = totalCost + costItem
END IF 

NEXT
%>
            <tr  bgcolor="#d9f5fa" >
              <td height="25" colspan="6"><table width="233" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="233"><label> </label>
                    <div align="right">
                      <input name="updateQ" type="hidden" id="updateQ" value="1" />
                      &nbsp;&nbsp;&nbsp;&nbsp;</div></td>
                </tr>
              </table>
                <span class="remove"> </span></td>
            </tr>
            <tr bgcolor="#d9f5fa">
              <td height="50"  colspan="6"> <table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="12" height="26">&nbsp;</td>
    <td width="170"><p>Total Cost: $<%=totalCost%>
      <input name="totalCost" type="hidden" id="totalCost" value="<%=totalCost%>" />
    </p>
     </td>
  </tr>
</table>
 </td>
            </tr>
            <tr bgcolor="#d9f5fa">
              <td height="44"  colspan="6">
         
         <table width="488" height="26" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="25">&nbsp;</td>
    <td width="446"><input name="input" id="input" type="submit" value="Update Cart" />
          <input type="submit" name="input" id="input" value="Keep Shopping" />
          <input type="submit" name="input" id="input" value="Checkout" /></td>
  </tr>
</table>

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
then in my asp when I try to see which button was pushed, how do I get back that number?

IF Request( "delete" ) = ???

in the first one

IF right(Request( "delete" ),6) = x

in the second one you need to find the request beginning with delete_ and take right(parm,7)