Javascript and asp.net - TextBox backcolor not changing...

A

avanti

i have a following javascript function that gets called on a checkbox
click. The backcolor is not getting changed for the textbox. I am
seeing an error on page as well. I am using IE and C# with the asp
code.

function enableExterNameTextBox(obj)
{
var textbox = "";
textbox = document.getElementById('partnerExternalName');
if(obj.checked)
{
alert('checked');
textbox.disabled = true;
textbox.value = "";
textBox.style.backgroundColor = 'gray';
}
else
{
alert('unchecked');
textbox.disabled = false;
textBox.style.backgroundColor = 'white';
}
}


Any ideas?
Thanks,
Avanti
 
S

Scott M.

Well, the code below works for me, but since you didn't provide the full
HTML code, I can't really say much more:

<HTML>
<HEAD>

<SCRIPT>
function enableExterNameTextBox(obj)
{
var tb = document.getElementById("partnerExternalName");
var cb = obj;

if(cb.checked)
{
alert("checked");
tb.disabled = true;
tb.value = "";
tb.style.backgroundColor = "#E0E0E0";
}
else
{
alert("unchecked");
tb.disabled = false;
tb.style.backgroundColor = "#FFFFFF";
}
}

</SCRIPT>
</HEAD>
<BODY>

<FORM ID="frmTest">
<INPUT TYPE="Checkbox" ID="chkColor" onClick="enableExterNameTextBox(this)">
<INPUT TYPE="TEXT" ID="partnerExternalName" />

</FORM>

</BODY>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top