onClick Toggle - Help Please!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sarah

    #1

    onClick Toggle - Help Please!

    Hi... I have a problem and I hope someone can help me out!

    I have two series of radio buttons...(call them Group A and Group B)
    and a Textarea.

    When you click on any of the radio buttons in the A group, it
    automatically adds some text to the textarea, using a javascript
    onClick function.

    When you click on any of the radio buttons in the B group, it appends
    another line of text to the existing text already in the textarea,
    again, using a javascript onClick function

    What I need is to make the group B onClick act like a toggle, so if
    the associated text isn't there, it will add it... but if it IS
    there... it will remove it.

    If that's not clear enough... here's an example

    ------------------------
    Group A
    Radio1 Radio2 Radio3 Radio4 Radio5

    Group B
    Radio1 Radio2 Radio3 Radio4 Radio5

    TextArea
    -------------------------

    If Group A/Radio1 is clicked it adds the text
    "Here is some text." to the textarea

    Then, if Group B/Radio1 is clicked it appends the text
    " And here is some more." to the existing text.... So the final text
    is: "Here is some text. And here is some more."

    If I then click GroupB/Radio1 again.... I'd like it to remove the
    GroupB/radio1 text, leaving the GroupA text alone and giving me just:
    "Here is some text"

    So.....

    Click GroupA/Radio1
    "Here is some text"

    Click GroupB/Radio1 once:
    "Here is some text. And here is some more"

    Click GroupB/Radio1 again:
    "Here is some text"

    Does that make sense? Can someone help me please?

    Thanks!. Sarah :)






  • Sarah

    #2
    Re: onClick Toggle - Help Please!

    Nevermind... I figured it out.... :p

    Comment

    Working...