By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

Add hidden fields to form onSubmit

P: n/a
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 item to MIVA (add to cart). Each form
has 4 hidden fields that are the same for every item and only one
hidden field plus the numbr of items textfield that changes.

I want to place all the hidden fields in one javascript function so I
only have to place the item number hidden field and the number of
items textfield in each product's form and the Add to Cart button
would call the javascript function. The javascript function would add
the generic hidden fields and then submit the form.

I've looked everywhere for how this can be done. Any ideas of
tutorials. Typical page in question can be seen at:
http://www.sunburstbottle.com/Merchant2/cat2.html

Thanks
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ivo
"Sam Wuebben" wrote:
I would like to add a few hidden field values to a form as it is
submited via JavaScript.
After looking at your site, and before putting in more energy, frankly, this
not a good idea. You don't want to miss those without 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 item to MIVA (add to cart). Each form
has 4 hidden fields that are the same for every item and only one
hidden field plus the numbr of items textfield that changes.

I want to place all the hidden fields in one javascript function so I
only have to place the item number hidden field and the number of
items textfield in each product's form and the Add to Cart button
would call the javascript function. The javascript function would add
the generic hidden fields and then submit the form.

I've looked everywhere for how this can be done. Any ideas of
tutorials. Typical page in question can be seen at:
http://www.sunburstbottle.com/Merchant2/cat2.html


document.forms.length returns 92 there. I would suggest setting up a system
which one form for all items.
HTH
Ivo
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.