I am new to javascript and am trying to do something that should be trivial but I am having difficulties. I have a javacript function that returns ad json array from a PHP backend database. I then extract this data and put it into different text boxes on my page. This part works just fine. for instance, the following code puts either a value of enabled or disabled into a textbox with an id of status.
[CODE]$(“#status”).val(result[‘gtt_account_status’]);
However, I wish to change the color of the text box depending on the value that is returned. So I tried many variations of the following:
[CODE]If ((document.getElementById(“status”).value) == “enabled”){
document.getElementById(“status”).style.backgroundColor = “lightgreen”;
}
As soon as I add this bit of code to my function, the data no longer gets put into the textbox at all. If I remove the if function and only add the
[CODE]document.getElementById(“status”).style.backgroundColor = “lightgreen”;
then the text box tuns light green like it should. I just cant seem to put this all together. below is the entire function.
[CODE]function insertResults(result){
$(“#status”).val(result[‘gtt_account_status’]);
If ((document.getElementById(“status”).value) == “enabled”){
document.getElementById(“status”).style.backgroundColor = “lightgreen”;
}
}
Any help would be most appreciated.