View Full Version : Forms / Checkboxes / Submitting form

05-29-2004, 04:56 AM
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:

<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">

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!


05-29-2004, 10:46 PM
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):

<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

05-29-2004, 11:27 PM
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,