Solved

JScript Form handling

Posted on 2011-09-20
4
272 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 51

Expert Comment

by:Huseyin KAHRAMAN
ID: 36570992
try:

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

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 51

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

Technology Partners: 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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

733 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