Solved

Highlight database output within a form

Posted on 2003-11-10
13
225 Views
Last Modified: 2013-12-24
I have the following code, and I would like to have the font be either bold or change color or something happen when the user clicks on one of the database outputs.  I currently have a column that puts an X next to the one that is selected.  I would rather have the entire row of data change as noted above.  How do I do this?

Here is the code.

  <cfoutput query="getaccountcontact">
  <tr>
    <td><cfif getaccountcontact.contactid eq #url.contactid#>X</cfif></td>
      <td><a href="index.cfm?account=#url.account#&contactid=#contactid#" class="basic">#trim(Contactlastname)#, #trim(contactfirstname)#</a></td>
      <td><table><tr><td>#contactareacode#-</td><td>#contactprefix#-</td><td>#contactnumber#</td></tr></table></td>
      <td>#extension#</td>
      <td>#trim(Department)#</td>
      <td>#trim(title)#</td>
      <td>#email#</td>
  </tr>
  </cfoutput>


Thanks.
0
Comment
Question by:swartout
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 9

Expert Comment

by:CFDevHead
ID: 9715427

 <cfoutput query="getaccountcontact">


----->  <tr  onClick="this.style.backgroundColor='whitesmoke'"> <---------


    <td><cfif getaccountcontact.contactid eq #url.contactid#>X</cfif></td>
     <td><a href="index.cfm?account=#url.account#&contactid=#contactid#" class="basic">#trim(Contactlastname)#, #trim(contactfirstname)#</a></td>
     <td><table><tr><td>#contactareacode#-</td><td>#contactprefix#-</td><td>#contactnumber#</td></tr></table></td>
     <td>#extension#</td>
     <td>#trim(Department)#</td>
     <td>#trim(title)#</td>
     <td>#email#</td>
  </tr>
  </cfoutput>
0
 

Author Comment

by:swartout
ID: 9715565
I saw where the background color changed, however, since I have the page "refreshing" with new criteria after you click, the color change goes away.
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 9716582
Then you probably need to set a cookie or something to trap the color change.  But I think I answered your first if you need the second question answered you should post a new question.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 2

Expert Comment

by:jonnygo55
ID: 9716665
I dont think you need to set a cookie try:

<cfoutput query="getaccountcontact">


 <tr <cfif getaccountcontact.contactid eq #url.contactid#>bgcolor="blue"</cfif>> <---------


     <td><a href="index.cfm?account=#url.account#&contactid=#contactid#" class="basic">#trim(Contactlastname)#, #trim(contactfirstname)#</a></td>
     <td><table><tr><td>#contactareacode#-</td><td>#contactprefix#-</td><td>#contactnumber#</td></tr></table></td>
     <td>#extension#</td>
     <td>#trim(Department)#</td>
     <td>#trim(title)#</td>
     <td>#email#</td>
  </tr>
  </cfoutput>
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9719022
Try this one :

  <cfoutput query="getaccountcontact">
  <tr onclick="document.location=''index.cfm?account=#url.account#&contactid=#contactid#"<cfif getaccountcontact.contactid eq #url.contactid#>bgcolor="blue"</cfif>>
    <td><cfif getaccountcontact.contactid eq #url.contactid#>X</cfif></td>
     <td><a href="index.cfm?account=#url.account#&contactid=#contactid#" class="basic">#trim(Contactlastname)#, #trim(contactfirstname)#</a></td>
     <td><table><tr><td>#contactareacode#-</td><td>#contactprefix#-</td><td>#contactnumber#</td></tr></table></td>
     <td>#extension#</td>
     <td>#trim(Department)#</td>
     <td>#trim(title)#</td>
     <td>#email#</td>
  </tr>
  </cfoutput>

Goodluck!
eNTRANCE2002 :-)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9720084
Yes u'll have to pass on the values in hidden form fields - so as to be able to show the rows clicked by teh users, in diff color even after refreshing.

if u have css - it wld make things a lot easier for u

PS : just use a identifier for each row & chk if the rowID is present in the list of selected rows using - listcontains.
0
 

Author Comment

by:swartout
ID: 9723016
entrance 2002, this works, however, can I change the font color rather than the background color?
0
 
LVL 2

Expert Comment

by:jonnygo55
ID: 9723687
you can change whatever you like...
<tr onclick="document.location=''index.cfm?account=#url.account#&contactid=#contactid#"<cfif getaccountcontact.contactid eq #url.contactid#>class="highlightedClass"<cfelse>class="basic"</cfif>>

just put the changes you like in the different css classes
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9727100
Sure ! you can change the font color.

You can have it this way :

  <cfoutput query="getaccountcontact">
  <tr onclick="document.location=''index.cfm?account=#url.account#&contactid=#contactid#"<cfif getaccountcontact.contactid eq #url.contactid#>bgcolor="blue"</cfif>>
    <td><cfif getaccountcontact.contactid eq #url.contactid#>X</cfif></td>
    <td><font color=<cfif getaccountcontact.contactid eq #url.contactid#>"blue"<cfelse>"red"</cfif>>
    <a href="index.cfm?account=#url.account#&contactid=#contactid#" class="basic">#trim(Contactlastname)#, #trim(contactfirstname)#</a>
    </font></td>
  <td>
  <table>
    <tr>
      <td><font color=<cfif getaccountcontact.contactid eq #url.contactid#>"blue"<cfelse>"red"</cfif>>#contactareacode#-
      </font></td>
      <td><font color=<cfif getaccountcontact.contactid eq #url.contactid#>"blue"<cfelse>"red"</cfif>>#contactprefix#-
      </font></td>
      <td><font color=<cfif getaccountcontact.contactid eq #url.contactid#>"blue"<cfelse>"red"</cfif>>#contactnumber#
      </font></td>
    </tr>
  </table>
  </td>
     <td>#extension#</td>
     <td>#trim(Department)#</td>
     <td>#trim(title)#</td>
     <td>#email#</td>
  </tr>
  </cfoutput>

Regards!
eNTRANCE2002 :-)
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9727121
Ooops! By the way, I forgot to remove the line :

    <cfif getaccountcontact.contactid eq #url.contactid#>bgcolor="blue"</cfif>

This line will cause conflict to the changing of font color 'coz I specify "blue" color for the font.  There would be a tendency that you might not see the text since its background is blue and font color is blue.  Better remove the specified line.

Thank you.

Best wishes!
eNTRANCE2002 :-)
0
 
LVL 14

Accepted Solution

by:
Renante Entera earned 125 total points
ID: 9728501
But actually to make it simplier, have it this way :

<tr onclick="document.location=''index.cfm?account=#url.account#&contactid=#contactid#"<cfif getaccountcontact.contactid eq #url.contactid#>style="color:blue"</cfif>>

Instead of setting font color column by column set it in a row passing a value for the parameter "style"...

See u!
eNTRANCE2002 :-)
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9735993
Thanks for the points and A.

Hope to help you again...

Regards!
eNTRANCE2002 :-)
0
 
LVL 2

Expert Comment

by:jonnygo55
ID: 9736023
wierd...I pretty much gave the accepted answer about 8 posts ago...
0

Featured Post

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question