Solved

JScript Form handling

Posted on 2011-09-20
4
268 Views
Last Modified: 2012-06-21
Hello,

I have a common form to send an item to a shopping cart. But this form shows a Button. I want to add now a text link to a blog where the user can add the item from a text link to the shopping cart.
I remember that in the past it was possible to do this "Form Action" with Java-Script, I think "OnClick" but Iam not really sure.  So my question to the experts:
How it is possible to send the form with a text link instead of a button.

Ocrana
<form method="post" action="">

<input type="hidden" id="my-item-id" name="my-item-id" value="1">
<input type="hidden" id="my-item-primkey" name="my-item-primkey" value="1">
<input type="hidden" id="my-item-name" name="my-item-name" value="MyProduct">
<input type="hidden" id="my-item-price" name="my-item-price" value="799.00">
<input type="hidden" id="my-item-shipping" name="my-item-shipping" value="">
<input type="hidden" id="my-item-img" name="my-item-img" value="http://www.ifoerster.com/wp-content/plugins/wpstorecart/images/default_product_img.jpg">
<input type="hidden" id="my-item-url" name="my-item-url" value="http://www.ifoerster.com/myproduct/">
<input type="hidden" id="my-item-tax" name="my-item-tax" value="0">
<input type="hidden" id="my-item-qty" name="my-item-qty" value="1">
<input type="hidden" id="my-item-variation" name="my-item-variation" value="0">
<input type="submit" name="my-add-button" value="Add to Cart" class="wpsc-button wpsc-addtocart " style="opacity: 1; ">

</form>

Open in new window

0
Comment
Question by:Ocrana
  • 3
4 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 36570992
try:

<a href="javascript.document.myForm.submit()">add</a>
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36570999
and give a name to your form

or use something like

document.forms[0].submit();
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36571000
<a href="javascript:void(0)" onclick="document.forms[0].submit()">Submit</a>

Open in new window

0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 36571005
oops, it should be:


if you have name on form:

<a href="javascript:document.myForm.submit()">add</a>

or

<a href="javascript:document.forms[0].submit()">add</a>

assuming it is the first form on document...
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now