View Full Version : js if then else help

03-08-2011, 02:08 AM
I am making a web site for my friend that sells wallets and other things. I am making an online order form for him. First you chose your product (in a select box) then you chose your color (in radio buttons). The problem is, each product has different possible colors, and I need the radio buttons to change text for each product? I think you need js to do this. Can someone please show me the code for this task?

03-08-2011, 03:38 AM
Are you sure this isn't some sort of homework exercise? because if it was genuine I would normally generate the html directly on the server using a server side language or AJAX.

Can you post your code you have so far and describe where you are currently storing the text that goes with each radio button depending on which product was chosen.

03-09-2011, 12:34 AM
No, it's not a homework project haha...
Here is the code:

<input type="radio" id ="color" name ="color 1 choice" />
<label for = "color1">Grey</label>
<br />
<input type="radio" id ="color1" name ="color 1 choice" />
<label for = "color">Red</label>
<br />
<input type="radio" id ="color2" name ="color 1 choice" />
<label for = "color">Blue</label>
<br />
<input type="radio" id ="color3" name ="color 1 choice" />
<label for = "color">Black</label>
<br />
<input type="radio" id ="color4" name ="color 1 choice" />
<label for = "color">Green</label>

03-09-2011, 06:19 AM
if you can do without the radio buttons and live with two select boxes there are a million of those around, already written, like this one (http://javascript.about.com/library/bldydrop1.htm)

03-09-2011, 06:40 PM
actually, I had another look at the link I sent and there seems to be a lot of set up time involved. I have a similar set up here (http://www.xelawho.com/map/drive.htm) using a slightly different technique which I remember not being so much work to fill in all the various options.

Or maybe I have forgotten. Maybe if you don't have so many combinations of options it doesn't matter so much. Anyway - here's (http://javascript.internet.com/navigation/connected-dropdown-box.html) the one I used, and like I say, there are a million others around.

03-09-2011, 11:34 PM
Thanks a million!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum