Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

force form submit() specify button

Posted on 2011-09-02
11
260 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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
Cannot open file from ASP if user is "logged in" 13 30
Generate Numbers in JQuery file 11 66
Dynamic Dropdowns 15 32
jQuery Dialog Autoresize Bug 2 24
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 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