Home All Groups Group Topic Archive Search About

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

Author
24 Oct 2006 8:52 PM
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

Author
25 Oct 2006 12:31 AM
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>

----------------------------------------------------------------



Show quoteHide quote
"avanti" <ava***@gmail.com> wrote in message
news:1161723150.488713.219220@m73g2000cwd.googlegroups.com...
>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
>