Solved

JScript Form handling

Posted on 2011-09-20
4
274 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
[X]
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
  • 3
4 Comments
 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
ID: 36570992
try:

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

Expert Comment

by:Huseyin KAHRAMAN
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 55

Accepted Solution

by:
Huseyin KAHRAMAN 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 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