Forum Moderators: open

Message Too Old, No Replies

onClick event with a checkbox!

help please..

         

dreamcatcher

11:14 pm on Jul 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Guys,

I`m writing a script that has a log in area and the user can choose to set a cookie if he wishes by clicking a checkbox. I have used the onclick() function to display a simple alert message when the box is checked. ie:


<input type="checkbox" name="cookie" value="yes" onclick="check()">

Javascript code:


<script language="JavaScript" type="text/JavaScript">
function check()
{

alert("NOTE!\n\nThis will keep you signed in on this computer for 30 days. This function is not recommended for shared computers.\n\nCookies must be enabled for this feature to work.\n\nThank you!");

}
</script>

This works fine, and the message appears if I check the box, however, when I uncheck the box, it appears again.

Is there a way to have the message appear ONLY when the box is checked?

Thank you!

Just realised I have posted in the wrong section. This can be moved to Javascript. Sorry about that. :(

dkin

12:54 am on Jul 23, 2004 (gmt 0)

10+ Year Member



I believe forum 91 will help you more than the php forum, seeing as this is a javascript problem.

[webmasterworld.com...]

Rambo Tribble

3:51 am on Jul 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onclick="if(this.checked)check();"

dreamcatcher

5:57 am on Jul 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Rambo Tribble, thank you very much, that works like a charm.

:)