?
Solved

Highlight a row when a button is clicked

Posted on 2006-11-06
5
Medium Priority
?
155 Views
Last Modified: 2013-12-24
I am using coldfusion and I want to be able to highlight a row in a recordset when an image button (row_btn) is clicked.

I have tried various options but whenever the row_btn is clicked the highlight disappears. This I assume is because the form is being submitted to the server.

The row_btn runs a query to retreive data specific to the id selected. It then displays the selected data in readonly form fields.

I am also storing the id to a session variable.

The recordset is in a div class called OrderDetails.

I want the highlight to remain on until another row is selected.

Please help.

thank you
0
Comment
Question by:Carid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:bwasyliuk
ID: 17883680
If your button is submitting back to the server - then you should have some kind of Row ID that you are using to get the details.

Assuming that - then when you are outputing the information - you can test for the row ID and highlight the appropriate row:

ex: (inside your CFloop or CFoutput of the query)

<cfif url.rowid eq myquery.rowid>
  <cfset variables.highlightcolor = "cfcfcf">
<cfelse>
  <cfset variables.highlightcolor = "White">
</cfif>
<div style="background-color:<cfoutput>#variables.highlightcolor#</cfoutput>;">the record detail goes here - if selected the row details will be highlighted.</div>

If I am off track, and you are trying to do something different - let me know.

Ben
www.scheduleforce.net
0
 

Author Comment

by:Carid
ID: 17893257
Hi Ben

Thanks for responding. I tried your solution but it didn't work.

I've included an extract of the code.  Maybe I'm missing something.
I've various method but to no avail.

What I want is the <TR> row to be highlighted when selected and remain selected until another is selected.

<cfform method="post" name="frmOrderEntry" ACTION="#cgi.script_name#"  >
<div class="OrdDetails" style="background-color:<cfoutput>#highlightcolor#</cfoutput>;">
<table >
<cfoutput query="getOrderLine">
  <cfif SESSION.A_OrdEntry.RowButton eq getOrderLine.instID>
    <cfset highlightcolor = "cfcfcf">
      <cfelse>
  <cfset highlightcolor = "white">
</cfif>

<cfinput type="hidden" name="InstID" value="#getOrderLine.InstID#">
<tr>
<td ><cfinput type="image" name="rowbutton"img src="/images/bullet.gif"       value="#getOrderLine.InstID#" /> </td>
  <td><cfInput type="text" name="SupplierName" value="#getOrderLine.SupplierName#" class="inputTxtLL" size = "25" Readonly="true"></td>
   
</tr>
</cfoutput>      
</table>
</div>
</cfform>


<cfif IsDefined('FORM.rowbutton.y')>

<cfset SESSION.A_OrdEntry.RowButton = #form.Rowbutton#>
</cfif>      

Thanks once again for your help
cheers Cari
0
 
LVL 7

Expert Comment

by:bwasyliuk
ID: 17893489
I don't see in your code where you are looping to create the different rows of the recordset - am I missing something...?
0
 
LVL 7

Accepted Solution

by:
bwasyliuk earned 750 total points
ID: 17893541
Sorry - I see it now...

The code::::::  style="background-color:<cfoutput>#highlightcolor#</cfoutput>;">

that you have on your DIV - should be on the TR

Also, you are checking SESSION.A_OrdEntry.RowButton but you should be checking a form variable that has been submitted back to the server...
0
 

Author Comment

by:Carid
ID: 17911466
Hi Ben
Sorry I've taken so long to get back. Been having problems with my ISP so no internet connection for a couple of days.

I've managed to sort it out.

I setup a hidden form with the value of the rowid and current row. (row_btn_#getOrderLine.CurrentRow#)
The code is as follows

<<cfinput type="Hidden" name="InsIDCount" value="#getOrderLine.RecordCount#">
      <cfoutput query="getOrderLine">
      <cfinput type= "hidden" name="row_btn_#getOrderLine.CurrentRow#" value="#getOrderLine.InstID#" />
      <cfif CurrentRow eq  #SESSION.A_OrdEntry.CurrentRow#>
           <cfset bgcolor = "blue">
      <cfelse>
            <cfset bgcolor = "white">
      </cfif>
   <tr bgcolor="#bgcolor#" >
    <td ><cfinput type="image"name="rowbutton"img src="images/bullet.gif"value="#getOrderLine.InstID#" /> </td>
    <td><cfinput name="delete_select"type="checkbox" value="#getOrderLine.InstID#" /></td>
    <td><cfInput type="text" name="SupplierName" value="#getOrderLine.SupplierName#" class="inputTxtLL" size = "25" Readonly="true"></td>


When the button is clicked it extracts the currentrow from row_btn_:

<cfif IsDefined('FORM.rowbutton.y')>
   <cfset SESSION.A_OrdEntry.RowButton = #form.Rowbutton#>
      <cfloop index="LoopCount" from=1 to=#Val(form.InsIDCount)#>
             <cfset variables.RowBtnID='form.row_btn_#Evaluate(LoopCount)#'>
            <cfif #evaluate(RowBtnID)# eq #form.Rowbutton#>
               <cfset SESSION.A_OrdEntry.CurrentRow = loopCount>
              </cfif>
       </cfloop>
</cfif>

Thanks for your help

cheers Cari
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

762 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