onClick Toggle - Help Please!

S

Sarah

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top