Somehow, my code does not work. I can’t figure out why, I’m completely new to javascript and thought this would work, in php it’s similar. if(string != “string”) works in PHP, but not in javascript, in javascript the code just continues. If I do it with =! it doesn’t works…
<SCRIPT LANGUAGE="JavaScript">
var lastsite;
function checkSite (form){
if (document.getElementById('steam').checked && lastsite != 'steam')
{
$('#signaturestuff').append('<b>Style:</b> <input type="radio" name="style" value="1" id="steamstyle1" onclick="testButton();"> Style 1');
var lastsite = "steam";
}
}
</SCRIPT>
You can compare strings with “==” in PHP and Javascript (but not in C, C++, C# or Java)
You probably should compare strings with Javascript compareLocale ()
In either case, you need to look at the value of “lastsite” in order to figure out why your comparison isn’t working. Who knows – maybe you just forgot to assign it 😉
Firebug is a wonderful tool, if you’re not already familiar with it.
“Javascript: The Good Parts” is a wonderful book, if you’ve not already read it.