473,671 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript set hidden fields and post form!

2 New Member
right off the bat - im a javascript noob so please forgive the question. im sure it is some stupid bit of syntax that i am missing, but im a middle tier developer trying to help out a friend!

so what im trying to do is post some form data from a javascript function that gets called from an anchor tag.. here are the relevant parts of the page code.

<html>
<head>
<script language="JavaS cript">
function setItemDetails( action,id,qty)
{
document.myform .pageAction.val ue = action;
document.myform .itemId.value = id;
document.myform .itemQty.value = qty;
document.myform .submit();
}

</head>
<body>
<form name="myform" action="http://myserver.com/cart.php" method="post">
<input type="hidden" name="pageActio n" value="0" />
<input type="hidden" name="itemId" value="0" />
<input type="hidden" name="itemQty" value="0" />

<a href="javascrip t:setItemDetail s('add_item',12 ,1)">Blah</a>
</form>
</body>
</html>

The idea was that the 'cart.php' page would get the POSTed data and use it, but i cant get the javascript function to fire. when i put "alert('test'); " in the href of the anchor tag it works, but for some reason it wont call the javascript function i have.

any help would be appreciated.
Apr 5 '07 #1
3 34900
dasien
2 New Member
sorry - after reading that post this morning, i realized i forgot the </script> tag. it is there is the code, but i didnt copy it to this message.

Any ideas on what else it could be would be helpful!
Apr 5 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
It works fine in Firefox. Which browser are you using?
Apr 5 '07 #3
iam_clint
1,208 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <head>
  4. <script language="JavaScript">
  5. function setItemDetails(action,id,qty)
  6. {
  7. alert("test");
  8. document.myform.pageAction.value = action;
  9. document.myform.itemId.value = id;
  10. document.myform.itemQty.value = qty;
  11. document.myform.submit();
  12. }
  13. </script>
  14. </head>
  15. <body>
  16. <form name="myform" action="http://myserver.com/cart.php" method="post">
  17. <input type="hidden" name="pageAction" value="0" />
  18. <input type="hidden" name="itemId" value="0" />
  19. <input type="hidden" name="itemQty" value="0" />
  20.  
  21. <a href="javascript:setItemDetails('add_item',12,1)">Blah</a>
  22. </form>
  23. </body>
  24. </html>
  25.  
worked fine in IE6
Apr 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3342
by: Hennie de Nooijer | last post by:
Hi everbody, Situation I created webpage with a receipt with javascript so when someone orders something from a product list a item is registered on the receipt. This works fine now. The next thing which i created is that the receipt works over multiple pages. So when someone pushes a link i read some hiddenfields (generated with javascript) into sessionvariables and a redirect to
1
9575
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the same name "junk_array". My first field of junk_array is a input type=hidden. All the others fields in junk_array that follow are type=text. I can reference this first hidden field in IE with document.form.field.value. In, fact my form works...
4
5385
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of product the visitor can order by clicking one or more checkboxes. I made a form containing input with type "checkbox" like: <form> <input type="checkbox" name=ck id=ck
1
3488
by: Sam Wuebben | last post by:
I would like to add a few hidden field values to a form as it is submited via JavaScript. I have a static page shopping site that uses MIVA shopping cart. Some of the pages are getting quite large and I want to start reducing the amount of code on each page. Replacing tables with divs are helping some but not as much as I would like. Some pages may have up to 100 different items on it and each one has its own form for submitting the...
5
7699
by: sams | last post by:
I've seen this covered before, but I just don't understand Java very well. I apologize if this is a repeat. Basically, I need a text/java style submit form with multiple hidden fields. It would take the place of the following standard submit button: <form action="ProductQuery.cfm" name="LineCode" method="post"> <input type="hidden" name="Year" value="#GetProducts.Year#"> <input type="hidden" name="Make" value="#GetProducts.Make#">
10
3103
by: Mark McLellan | last post by:
Dear all Following the oft-repeated advice here and ciwas I have made my site nearly 4.01 strict (working on it). There are some items on which I would appreciate your advice: 1. Hidden fields http://www.zoo.co.uk/~mmenterprises/contact.htm I am using FormMail from Matt's Script Archive. The W3C validator objected to the hidden fields unless I put, say, P round them. That gave
0
2072
by: BcNexus | last post by:
Hello all, The search function of this forum isn't working although I found a similar question on the forum using Google, but the replies don't help me. So, forgive me please if this has been answered before. I have a cgi program in Python that genereates an HTML page with a form with hidden fields whose values are set via the following: ##Print hidden "usernameH", "passwordH", "timeH", "checksumH", and toPageH, fields with value attribs...
5
7338
by: dmorand | last post by:
I'm having a strange issue with a form I'm developing. I'm saving some values to hidden fields when a user clicks a button. I setup a function which gets ran on submission of the form, but I also placed this function on my submission button when clicked. <input name="button5" type="button" class="Buttons" id="button5" value="On File" OnClick="setup_req('cpr_onfile',1);"/> <input type="hidden" name="cert_onfile"/> ..... <cfform...
11
3095
by: viki1967 | last post by:
Hidden field Hello my friends. This is a htm page that contains a form open in window popUp ( page daughter ). This form insert a value in the one hidden field called "tec", in other form open in the page mother. As you can see the select contains multiple attribute.
1
1044
by: DigDag | last post by:
Hi Everyone, this is my first post here. This may sound weird or silly but I have an HTML form and used javascript to validate fields and I use a CGI to process the data. There are hidden fields too, but I don't want them to be seen in the email that I receive after submitting the form. I can't modify the CGI, because I don't have permissions but I'm allowed to use it to process the data. I just have access to the HTML page and javascript...
0
8401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8824
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6236
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2818
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.