Javascript Help Please

twister

Howdy
Can anyone help me? I know PHP but not much javascript but i need some radio button values to change on the fly but don't know how. Here is how it works.

If the user inputs a number between 0-49 then radio button a is .50 radio button b is .45 and radio button c is .42

If the user inputs a number between 50-99 then radio button a is .40 radio button b is .38 and radio button c is .33

If the user inputs a number 100+ then radio button a is .38 radio button b is .35 and radio button c is .30

That's the general idea. But how i do that? I need to start with an if statement and then re-assign the radio buttons after that but i'm stuck. Can anyone help?

Thanks ;)
 
If you are talking about the text labels for the radio buttons, they're not really part of the radio button and so there's no radio button attribute to change.

What you can do (modern browsers only) is the place the labels in span tags, give them an id, and then change the contents of the span.

For example:

Code:
<span id="radioLabel1">whatever</span>

and in the script

Code:
document.getElementById( 'radioLabel1' ).innerHTML = 'something new!';

Is that what you were after?

If you also need to change the values that get submitted with the form for the radio group, that can be done as well...

bear
 
I kind of got it to work using a dynamic drop down menu script i found. It was confusing but it worked it out. I think. Basically it works like this.

If you choose to buy 50 widgets you then can get them colored. Red = $.50 or Blue = $.75 or Green = $.88 cents/each

If you choose to buy 100 widgets then you can get them colored cheaper.
Red = $.25 or Blue = $.50 or Green = $.70 cents/each

Get the idea? the more you choose the cheaper the same three options get. And i want that to happen right away, no page refresh.

Thanks
 
Back
Top