Jump to content

checkboxes


plutomed

Recommended Posts

i hate writing javascript but is very useful

can anyone tell be what is wrong

 

<script type="text/javascript" language="javascript">
function check()
{
if(document.getElementById("check").checked=true)
{
	document.getElementById("showemail").value="0"
}
else if(document.getElementById("check").checked=false)
{
	document.getElementById("showemail").value="1"
}
}
</script>

Link to comment
https://forums.phpfreaks.com/topic/38684-checkboxes/
Share on other sites

i hate writing javascript but is very useful

can anyone tell be what is wrong

 

<script type="text/javascript" language="javascript">
function check()
{
if(document.getElementById("check").checked=true)

 

You are assigning the value true, rather than checking it (i.e. use "==" not "=").

 

It is simpler and less error-prone to write:

 

  if (document.getElementById("check").checked)

 

 

Link to comment
https://forums.phpfreaks.com/topic/38684-checkboxes/#findComment-185971
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.