Add hidden fields to form onSubmit

S

Sam Wuebben

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
 
I

Ivo

Sam Wuebben said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top