Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.