Solved

force form submit() specify button

Posted on 2011-09-02
11
257 Views
Last Modified: 2012-08-13
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?
0
Comment
Question by:rivkamak
  • 3
  • 2
  • 2
  • +1
11 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36475486
<form onsubmit="return false;">
And onclick of your image button :
OnClick="document.forms[0].onsubmit=null"
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36475491
<form onsubmit="return false;">
And onclick of your image button :
OnClick="document.forms[0].onsubmit=null;document.forms[0].submit()"
0
 
LVL 29

Expert Comment

by:Badotz
ID: 36476063
Instead of inlining your JavaScript, create a function to do the submittal and forget form onsubmit="return false; altogether.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:rivkamak
ID: 36482083
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?
0
 
LVL 29

Expert Comment

by:Badotz
ID: 36482249
Pass a parameter to the ASP page, either in a hidden text field or in the URL.
0
 

Author Comment

by:rivkamak
ID: 36497563
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

0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 37114342
How about

<input type="submit" name="delete" id="delete" value="Delete item <%'=i%>" />

or

<input type="submit" name="delete_<%'=i%>" id="delete<%'=i%>" value="Delete" />
0
 

Author Comment

by:rivkamak
ID: 37115281
then in my asp when I try to see which button was pushed, how do I get back that number?

IF Request( "delete" ) = ???

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37116035
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)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
show form submit button based on jquery sum 5 28
what are list of ebay api errors 1 19
Javascript_Set_dropdown_value 7 32
Diminish Pop-up  in 3 seconds 7 19
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question