Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed (Author was flagged for spam)

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

6
[Javascript] Simple issue involving radio button groups and calculating price realtime
Author Summary
Slyvr89 is in javascript
Post Body

I don't have a lot of experience working with javascript so this is probably an easily answerable question. I have an issue where I have several radio button groups and when one is clicked, it needs to run the function calcPrice() which will then change the value of the price text box. The first radio button group is for size and looks like this:

<input type="radio" name="size" value="Mini" onclick="calcPrice();" />Mini&nbsp;&nbsp;&nbsp;
<input type="radio" name="size" value="Small" onclick="calcPrice();" />Small&nbsp;&nbsp;&nbsp;
etc...

The next radio button groups are generated from php and end with a result like this:

<font color="red">1) Pepperoni</font><br />
        <input type="radio" id="ingredient" name="Pepperoni" value="Left" onclick="calcPrice();" />Left&nbsp;&nbsp;&nbsp;
        <input type="radio" id="ingredient" name="Pepperoni" value="Whole" onclick="calcPrice();" />Whole&nbsp;&nbsp;&nbsp;
        <input type="radio" id="ingredient" name="Pepperoni" value="Right" onclick="calcPrice();" />Right&nbsp;&nbsp;&nbsp;<br /><br />
                <font color="red">2) Sausage</font><br />
        <input type="radio" id="ingredient" name="Sausage" value="Left" onclick="calcPrice();" />Left&nbsp;&nbsp;&nbsp;
        <input type="radio" id="ingredient" name="Sausage" value="Whole" onclick="calcPrice();" />Whole&nbsp;&nbsp;&nbsp;
        <input type="radio" id="ingredient" name="Sausage" value="Right" onclick="calcPrice();" />Right&nbsp;&nbsp;&nbsp;<br /><br />

For some reason when I click on any radio button, it deselects any other radio button on the page. I can only have one radio button selected at a time even though all their names are different. Why does it do this and how can I make it not do that?

Edit: the code: http://jsbin.com/eziyal/1/edit

Edit2: solved! Thanks hbish

Author
Account Strength
0%
Account Age
14 years
Verified Email
Yes
Verified Flair
No
Total Karma
14,598
Link Karma
5,756
Comment Karma
8,842
Profile updated: 8 months ago
Posts updated: 1 year ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
12 years ago