onclick check right radio button

Discussion in 'JavaScript' started by luvkycool, Nov 17, 2005.

  1. #1
    Hi there folks,after a great help from tommy the other day,
    i finally managed to perfection what i wanted to archive.

    However to make the user experience nicer,i need to know one more thing to make my application the killer application=)

    Basicallly to recap a little what ive done.

    I have a colorpallete, and 7 attributes that can be filled.
    each attribute stands for a radiobutton,next to the radiobutton is a textfield with the selected color for that attribute,which change as you click another color.

    Now this works great,but since people can also put instead of selecting a color from the pallete a color theirself
    it happens people forget to select the attribute for that .
    And so i would like that when a person clicks on a textbox(next to the attribute) that that radiobutton gets checked automatically instead of finding out later that the wrong radiobutton was checked and that for this the color filled the wrong attribute.

    Ups i see i typed alot,hope it makes sense
    a little code is this:

    <label>
    <input type="radio" name="attributes" value="backgroundColor" checked>

    <b>B</b>ackground </label></td><td>
    <input type="text" name="backgroundcolortextfield" size="7" onclick="document.form1.attributes.backgroundColor.value=checked" onchange="return shouldsetbg(this.value)" value="#FFFFFF">

    And i m getting the error with this one:

    onclick="document.form1.attributes.backgroundColor.value=checked"

    hope anyone can shed some light:)
    thanks
     
    luvkycool, Nov 17, 2005 IP
  2. torunforever

    torunforever Peon

    Messages:
    414
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try

    onclick="document.form1.attributes[0].checked=true"
     
    torunforever, Nov 17, 2005 IP
  3. luvkycool

    luvkycool Guest

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    perfect!

    thanks
     
    luvkycool, Nov 17, 2005 IP