Solved

Highlight a row when a button is clicked

Posted on 2006-11-06
5
149 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

16 Experts available now in Live!

Get 1:1 Help Now