Solved

JScript Form handling

Posted on 2011-09-20
4
258 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
Comment Utility
try:

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

Expert Comment

by:HainKurt
Comment Utility
and give a name to your form

or use something like

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

Expert Comment

by:leakim971
Comment Utility
<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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to dynamically set the form action using jQuery.

744 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

16 Experts available now in Live!

Get 1:1 Help Now