[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

JScript Form handling

Posted on 2011-09-20
4
Medium Priority
?
279 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 60

Expert Comment

by:HainKurt
ID: 36570992
try:

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

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 60

Accepted Solution

by:
HainKurt earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

650 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