Re: Identifying an empty field to change the backgorund color of t by GillesABelanger
GillesABelanger
Thu Jan 26 10:51:05 CST 2006
Good morning,
Here is exactly what I have:
<SCRIPT language=vbscript event=onchange for=Tickets_OrderNu>
<!--
if document.getElementById("Tickets_OrderNu").value<>0 then
CICODE.disabled= False
Quantity.disabled= False
document.getElementById("Tickets_OrderNu_Label").style.backgroundcolor=RGB(0,&HFF,0)
document.getElementById("CICODE_Label").style.backgroundcolor=RGB(0,&HFF,0)
document.getElementById("Quantity_Label").style.backgroundcolor=RGB(0,&HFF,0)
document.getElementById("CICODE").style.backgroundcolor=RGB(255,255,255)
document.getElementById("Quantity").style.backgroundcolor=RGB(255,255,255)
MsgBox "You need to enter values in the next two fields below, CICODE and
Quantity for this CICODE.",48, "Data entry rules."
Elseif document.getElementById("Tickets_OrderNu").value="" or _
document.getElementById("Tickets_OrderNu").value=0 then
CICODE.disabled= True
Quantity.disabled= True
document.getElementById("Tickets_OrderNu_Label").style.backgroundcolor=RGB(192,192,192)
document.getElementById("Quantity_Label").style.backgroundcolor=RGB(255,255,255)
document.getElementById("CIcode").style.backgroundcolor=RGB(230,230,230)
document.getElementById("Quantity").style.backgroundcolor=RGB(230,230,230)
End if
Everything works except the line where the .value=""
I am new at vbscript and I do not see the difference between your approach
which is to declare a variable and this approach which is to compare the
value directly to "". Please help me to understand.
Thanks
--
GillesABelanger
"Bob Barrows [MVP]" wrote:
> Please post the html of a small repro page where this does not work. Start
> with:
>
> <HTML>
> <HEAD>
> <SCRIPT type="text/vbscript" LANGUAGE="vbscript">
> sub btnchange_onclick()
> dim input
> set input=document.getElementById("Tickets_OrderNu")
> if input.value="" then
> input.style.backgroundcolor="silver"
> else
> input.style.backgroundcolor="yellow"
> end if
> end sub
> </SCRIPT>
> </HEAD>
> <BODY>
> <INPUT id="Tickets_OrderNu" type="text" value=""
> style="background-color:silver">
> <INPUT type="button" id="btnChange" value="Change Color">
> </BODY>
> </HTML>
>
> Show us how to reproduce your problem
>
> Bob Barrows
> GillesABelanger wrote:
> > Using "" is not working. Is there any other method to reflect a
> > cleared field? --
> > GillesABelanger
> >
> >
> > "deckhopper" wrote:
> >
> >> Try this:
> >>
> >> document.getElementById("Tickets_OrderNu").value = ""
> >>
> >> Referred to as an "empty string" --> two double-quotes with NO space
> >> in between them.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
>