Jump to content

Function doesn't seem to parsing


Noongar

Recommended Posts

I have a problem where my function doesn't seem to be even parsing.

 

<SCRIPT>
function unknownName() {
	if (document.forms['form']['targetname'].disabled = false) {
		document.forms['form']['targetname'].disabled = true;
	}
	if (document.forms['form']['targetname'].disabled = true) {
		document.forms['form']['targetname'].disabled = false;
	}
}
</SCRIPT>

<INPUT name="unknownname" onclick="return unknownName()" type="checkbox">

 

When I click it, the INPUT that its suppose to disable doesn't disable. I don't even get an error message in my error console which suggests that the function isn't even parsing. Does anyone know what the problem is?

Link to comment
https://forums.phpfreaks.com/topic/258961-function-doesnt-seem-to-parsing/
Share on other sites

Your right about the equal signs man. How didn't I see this! Thanks!

 

"your if statments will cancel each other if the field is disabled. Maybe you need to use else if."

 

I don't understand what you mean. Could you give me an example?

 

Now my error console reports "unknownName is not defined". How is that so?!

If the field was not disabled and you called the function, the first if statment will disable it and the second if statment will check if it's disabled (and it's because the first if statment) and enable it. instead you can if else statment instead of two if statments.

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.