Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Forms / Checkboxes / Submitting form

    I am fairly new to Javascript, and I am having trouble figuring out something that I have a feeling is pretty simple.

    I need to send information to a Shopping Cart Back-End. The information needs to be sent via a standard HTML 'POST' command.

    The 'catalog' of items on the index screen of my HTML page has checkboxes next to each item. Multiple items can be checked on the same screen.

    All of the checked items need to be submitted in a single 'POST / SUBMIT' step, since submitting the form immediately takes me to the shopping cart... in other words, I can't do a separate submit for each item.

    The general format of the FORM is:

    <body>
    <form METHOD="POST" NAME="PrintPicture" ACTION="http://www.printroom.com/AddImageToCart.asp">
    <input type="HIDDEN" name="image_thumb" value="http://www.aa.com/image/image1_t.jpg">
    <input type="HIDDEN" name="image_thumb" value="http://www.aa.com/image/image2_t.jpg">
    </form>
    <SCRIPT LANGUAGE="JavaScript">
    document.PrintPicture.submit();
    </SCRIPT>
    </body>

    How can I 'build' something that when POSTed, will have several copies of the same item name, but with different values? Looping and setting values just sets the last item's value.

    I hope that I'm giving enough info to be understood.

    Thanks in advance!

    Edward

  • #2
    Rex
    Rex is offline
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello Edward -

    I assume the hidden inputs are generated by a server side script. If they are, generate them so you get all image names in one input, separated with semicolons (or whichever delimeter you prefer):
    Code:
    <input type="hidden" name="image_thumb" value="http://www.aa.com/image/image1_t.jpg; http://www.aa.com/image/image2_t.jpg">
    The script, when parsing the form data, can then split up the image file names to an array, using the respective splitting function in that language. All server side languages probably have a function for splitting a string into an array.

    - Rex
    Sincerely,
    Rex

  • #3
    New to the CF scene
    Join Date
    May 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Figured it out.

    Thanks for the help.

    What I ended up doing was building a string that contains the entire statement, properly formatted, basically by adding sentences over and over to the same string through a loop.

    A 'document.write' of the entire statement, including the 'submit' command, gets the info transfered properly.

    Once the lightbulb went on, it was not so hard.

    Thanks again,

    Edward


  •  

    Posting Permissions

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