Skip to main content
Inspiring
June 14, 2006
Answered

<cfif> </cfif>

I have an <input type="text" name="pnum">

I want to the color of my text area to change if pnum is left blank....

I am cloudy on how i should get this done and was wondering if i could get some advice

i thought it should work like

<cfif IsDefined("pnum")>
This topic is closed to new replies. Start a new post to keep the conversation going.
Newsgroup_UserCorrect answer
Inspiring
June 14, 2006
try it this way

<td align="center" class="bottomLine" ><input style="border:0;<cfif
Len(pnum) IS 0> background-color:Yellow;</cfif>" type="text"
name="pnum#cnt#" value="#res.phone#" maxlength="13" size="10"></td>



--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
=============================
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"PackinDaMAC" <webforumsuser@macromedia.com> wrote in message
news:e6p9on$1e5$1@forums.macromedia.com...
> Here is how i did it...My page loads but it does not change the color
> though....What am I missing???
> <td align="center" class="bottomLine" ><input style="border:0;
> background-color:transparent" type="text" name="pnum#cnt#"
> value="#res.phone#"
> maxlength="13" size="10" style="background-color:<cfif Len(pnum) IS
> 0>Yellow</cfif>"></td>
>


9 replies

Inspiring
June 14, 2006
I wonder if something like this isn't better handled by JavaScript.

If you user CF to set the textbox's color, then it only changes on pageload. For instance, it could be blank when the page loads initially, but then the user may enter something but the textbox's color won't change until the next pageload.

If, on the other hand, you use Javascript in the textbox's onChange event to evaluate the textbox's status (blank or not) and then update the textbox's color, then the color will change whenever the user edits the textbox.
Translate
Newsgroup_UserCorrect answer
Inspiring
June 14, 2006
try it this way

<td align="center" class="bottomLine" ><input style="border:0;<cfif
Len(pnum) IS 0> background-color:Yellow;</cfif>" type="text"
name="pnum#cnt#" value="#res.phone#" maxlength="13" size="10"></td>



--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
=============================
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"PackinDaMAC" <webforumsuser@macromedia.com> wrote in message
news:e6p9on$1e5$1@forums.macromedia.com...
> Here is how i did it...My page loads but it does not change the color
> though....What am I missing???
> <td align="center" class="bottomLine" ><input style="border:0;
> background-color:transparent" type="text" name="pnum#cnt#"
> value="#res.phone#"
> maxlength="13" size="10" style="background-color:<cfif Len(pnum) IS
> 0>Yellow</cfif>"></td>
>


Translate
Inspiring
June 14, 2006
Here is how i did it...My page loads but it does not change the color though....What am I missing???
<td align="center" class="bottomLine" ><input style="border:0; background-color:transparent" type="text" name="pnum#cnt#" value="#res.phone#" maxlength="13" size="10" style="background-color:<cfif Len(pnum) IS 0>Yellow</cfif>"></td>
Translate
Inspiring
June 14, 2006
What exactly do you mean by 'left blank'? When the form is loaded? When submit is clicked? After some validation? Please be more specific.
Translate
Inspiring
June 14, 2006
When the form loads on to the screen there are some that phone numbers are left blank and those phone numbers that are blank i want that area in my table to change color???? Is this not practical using cfml????
Translate
Inspiring
June 14, 2006

<input type="text" name="pnum" style="background-color: <cfif Trim(pnum) IS "">Black<cfelse>White</cfif>" >
Translate
Inspiring
June 14, 2006
<cfif IsDefined("pnum")>
<cfif Len(pnum) IS 0>
<cfset bgcolor = "FFFFF">
</cfif>

</cfif>
Would this be correct or am i not using the right logic???
Translate
Inspiring
June 14, 2006
Ok so that would check the length of the string so to change the color

<cfif Len(pnum) IS 0>
<cfset pnum = "FFFFF">
</cfif>

Is that how it would work??? or am i missing something???
Translate
June 14, 2006
<CFIF Len(pnum) IS 0>
Translate