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" Quote Link to comment 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") { Quote Link to comment Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 deleted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.