www.webdeveloper.com
Results 1 to 6 of 6

Thread: can't pass value to form

  1. #1
    Join Date
    Sep 2003
    Posts
    14

    can't pass value to form

    I am trying to pass a vaule to a text field in a form and am having trouble doing so. I have images with javascript like this
    Code:
    <img src="/images/add.jpg" width="19" height="19" alt="Add Your Selection" border="0" onClick="parent.passclr(clr_array = new Array('5233-12'));">
    which calls this function
    Code:
    function passclr(clr_array) {
    document.order_form.id[2].value = clr_array[0];
    }
    and this form
    Code:
    <form name="order_form" action="http://www.mysite.com/product_info.php/action/add_product" method="post">
    Product:<br />
    <input type="text" size="15" name="pro" value=" " /><br />
    Model #:<br />
    <input type="text" size="5" name="mod" value=" " /><input type="text" size="5" name="products_id" value=" " /><br />
    Upholstery #:<br />
    <input type="text" size="15" name="id[2]" value=" " /><br />
    Starting Price:<br />
    <input type="text" size="15" name="spr" value=" " /><br />
    Upholstery Price:<br />
    <input type="text" size="15" name="upr" value=" " /><br />
    Total:<br />
    <input type="text" size="15" name="tot" value=" " /><br /><br />
    <input type="image" src="/images/add_to_cart.jpg" width="80" height="20" alt="Add To Cart" border="0">
    </form>
    The problem is with the [] in the name of the field id[2]. If I change the name the script works fine, but I have to have it called id[2] because of the shopping cart program I am using. Any ideas on how to get the value to the text field?

  2. #2
    Join Date
    Dec 2002
    Location
    WI, United States
    Posts
    1,372
    This should work:

    document.formname.elements["id[2]"].value
    if (succeed != true)
    function askAdam();

    Check out my site!

  3. #3
    Join Date
    Sep 2003
    Posts
    14
    I am not sure if this what you mean. It does not work.
    Code:
    document.order_form.["id[2]"].value = clr_array[0];

  4. #4
    Join Date
    Dec 2002
    Location
    WI, United States
    Posts
    1,372
    You didn't look at what I had...

    Try this:

    document.order_form.elements["id[2]"].value = clr_array[0];
    if (succeed != true)
    function askAdam();

    Check out my site!

  5. #5
    Join Date
    Sep 2003
    Posts
    14
    Ok, thanks! It is working now.

  6. #6
    Join Date
    Dec 2002
    Location
    WI, United States
    Posts
    1,372
    lol, no problem.
    if (succeed != true)
    function askAdam();

    Check out my site!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles