Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question js if then else help

    Hello,
    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?
    Thanks,
    benbeast

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Cool

    No, it's not a homework project haha...
    Here is the code:

    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>
    </div>
    Thanks!

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,989
    Thanks
    56
    Thanked 557 Times in 554 Posts
    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

  • Users who have thanked xelawho for this post:

    benbeast (03-09-2011)

  • #5
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,989
    Thanks
    56
    Thanked 557 Times in 554 Posts
    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 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 the one I used, and like I say, there are a million others around.

  • Users who have thanked xelawho for this post:

    benbeast (03-09-2011)

  • #6
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks a million!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •