Need script help for order page!

Jaiem's picture

They have: 1,191 posts

Joined: Apr 1999

I need some help with JavaScript for an an e-commerce site.
The site will use a shopping cart script and the cart receives the product info via HTML Form tags (form tags for price, quantity etc). The items sold will have multiple options. Depending on the option the customer selects the price changes. That is, the value of the form's PRICE tag will need to change. I decided to use radio buttons for selecting the options for each item.

Here's whatI need:

I need some JavaScript that will detect if a given radio button has been CHECKED. If it has been checked then the JS need to change the value of the PRICE tag for that form.

Any help would be appreciated!

Thanks in advance!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

uhhh...
why are you using radio buttons? shouldn't you use checkboxes?

can you give an exampe? (you mean like choosing RAM size: 128,256,512..?)

<input type=radio name=item1 value=10>$10 for 128MB
<input type=radio name=item1 value=20>$20 for 256MB
<input type=radio name=item1 value=30>$30 for 512MB
'

Mark Hensler
If there is no answer on Google, then there is no question.

Jaiem's picture

They have: 1,191 posts

Joined: Apr 1999

Mark,

The client wants to display all the options for each item BUT only wants the customer to be able to select one option per item. IOW, with each click of the ADD TO CART button the customer can only make one option choice. And since the client wants all the options displayed I feel a radio button is better than a drop-down list. A check box wouild work if they could select multiple options. But they can't.

Your example code is correct. Depending on which radio button the customer clicks I want to be able to set the value of the hidden PRICE tag in the form.

IOW, I will hard code in the form and based on the radio button clicked I need JS code to change the value of the PRICE tag to something else.

Thanks!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.