Reputation: 175
I have an asp based shopping cart that uses html based templates to display products. In each product section I have several items and each item has both a price per single "pack" of the item and a price for a "case" of that item. Under each price for "pack" there is a quantity text box and a submit button for that, and right next to it is a price for the cases of that item, a quantity text box, and a submit button for that. Normally this works just fine because everything has a different value and it's easy to have the 2 separate forms (one for "pack" and one for "case") in each product listed on the page.
However, I came across a problem in which one of the products has an option that is set up by the use of radio buttons. Now the radio button "features" are displayed while I'm setting up the form for the "packs" and whatever selection the user picks is properly displayed when they press the submit button for a "pack". However, when they order a "case", since it is a separate form, it doesn't see the "feature" value and pass it along with the case submit button press.
The question is, can you set up some radio buttons and have them pass whatever item is selected to 2 different submit buttons? As I have it now, the pack starts up the form code and then inside of that I have the case form. I have put in some simplified code below. The things like Product: and Features: are just dummy text in place of all the formatting junk that isn't relevant to this question. The html code that I show below is the only part that I'm trying to change.
<form action="addtocart.asp" method="post">
<input name="productid" value="11" type="hidden">
Product:
Features:
Options:
<input checked="checked" name="Feature" value="1" type="radio">Option1
<input name="Feature" value="2" type="radio">Option2
<input name="Required" value="8" type="hidden">
Price Per Pack:
Quantity:
<input class="txtfield" maxlength="4" size="3" value="1" name="quantity" type="text">
Pack Submit Button:
<input class="submitbtn" value=" Order " name="Order" type="submit">
Price Per Case:
<form name="casename" action="addtocart.asp" method="post">
Quantity:
<input class="txtfield" maxlength="4" size="3" value="1" name="quantity" type="text">
<input name="productid" value="24" type="hidden">
Case Submit Button:
<input class="submitbtn" value=" Order " name="Order" type="submit">
</form>
The "Options" section above is where they are selecting the radio button choice, so is it possible to have each submit button pass this information along or do I need to use javascript or something like that?
Thanks for taking a look at my question!
Upvotes: 0
Views: 1168
Reputation: 4183
forms values are independent, so you have two options:
Also, you can't or shouldn't have a form inside a form as far as I know. It may work ok in some browsers, but it's invalid HTML
Upvotes: 1