Solved

Highlight a row when a button is clicked

Posted on 2006-11-06
5
150 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
  • 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 250 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

Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now