d22552000 Posted March 10, 2008 Share Posted March 10, 2008 function buttoncase(id) { var i = document.getElementById(id); var a = document.getElementById("is" + id); if (a = true) { i.class = "buttons"; a.value = "false"; //PICK ME, I'M LINE 7 } else { i.class = "buttons2"; a.value = "true"; } } I have made hidden form tags for all my isname fields, and yet I get: "Line 7, character 5, expected identifier" Link to comment https://forums.phpfreaks.com/topic/95349-javascript-buttons/ Share on other sites More sharing options...
nogray Posted March 12, 2008 Share Posted March 12, 2008 You have a few issues with your code i.class = "buttons"; To assign a class name to an object, you should use className, so your code will be i.className = "buttons"; if (a = true) First a is an object (not a boolean) assuming it's an input field you can access it's value using the value attribute a.value for comparson use the douple == signs otherwise the statment will always be true since it's only assigning true to a Finally, all input values are strings so to compare it to a boolean will return false. Your if statment should look like this if (a.value == "true") { Link to comment https://forums.phpfreaks.com/topic/95349-javascript-buttons/#findComment-490586 Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 deleted. Link to comment https://forums.phpfreaks.com/topic/95349-javascript-buttons/#findComment-490590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.