Add hidden fields to form onSubmit

Discussion in 'Javascript' started by Sam Wuebben, Aug 6, 2004.

  1. Sam Wuebben

    Sam Wuebben Guest

    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
    Sam Wuebben, Aug 6, 2004
    #1
    1. Advertising

  2. Sam Wuebben

    Ivo Guest

    "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
    Ivo, Aug 6, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q3Jpc3RpYW4gQ2FybHNzb24=?=

    Re: Add onSubmit To Form?

    =?Utf-8?B?Q3Jpc3RpYW4gQ2FybHNzb24=?=, May 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    675
    Steven Cheng[MSFT]
    May 27, 2004
  2. Replies:
    0
    Views:
    279
  3. Replies:
    1
    Views:
    90
  4. vunet
    Replies:
    1
    Views:
    100
    Thomas 'PointedEars' Lahn
    Jul 28, 2008
  5. Replies:
    23
    Views:
    493
    Tim Streater
    Dec 18, 2013
Loading...

Share This Page