Add hidden fields to form onSubmit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sam Wuebben

    Add hidden fields to form onSubmit

    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:
    Shop Berlin Packaging, a hybrid packaging company supplying wholesale bottles, containers, innovative design & more across all markets. Free shipping over $300!


    Thanks
  • Ivo

    #2
    Re: Add hidden fields to form onSubmit

    "Sam Wuebben" wrote:[color=blue]
    > I would like to add a few hidden field values to a form as it is
    > submited via JavaScript.[/color]

    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.
    [color=blue]
    > 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[/color]

    document.forms. length returns 92 there. I would suggest setting up a system
    which one form for all items.
    HTH
    Ivo


    Comment

    Working...