Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Javascript sort on table not working on lightbox popup

Posted on 2009-07-07
5
Medium Priority
?
520 Views
Last Modified: 2012-10-10
All,

I have added a the code from http://www.kryogenix.org/code/browser/sorttable/ to sort a table on my php page.  A lightbox popup is also used on this page that gives more information based on what you clicked on the parent page.  The popup is a table that needs to be sortable; however, I am unable to get the sortable.js to work on my popup.

I do not get any errors on the page or the popup. Please note there are two different pages in the code below.  I have spoken with the author of the sorttable.js and he did not see anything wrong with the way I was using the code; thererfore, I believe it has more to do with conflicting scripts between the sorttable.js and the lightbox HoverDivMethods.js.

All files (except the Lightbox js) are located in the same folder on the same drive.
********************************Main Page***********************************************
<?php
 
	include 'Standardcode/Connections.php';
	
	//****************************  QUERIES   ***********************************
	
	$SQLAll = "SELECT * from table
		WITH UR";
		
		
	$RESULTS= odbc_exec($DB2Q,$SQLAll);
 
	
?>
<HTML>
<HEAD>
	<STYLE TYPE="text/css">
			.black_overlay{
			 visibility :hidden;
			 top: 0%;
			 left: 0%;
			 width: 100%;
			 height: 100%;
			 background-color: black;
	
			 position: absolute;
			 -moz-opacity: 0.4;
			 opacity:.40;
			 filter: alpha(opacity=40);	 
			}
	
	</STYLE> 
	
	<SCRIPT LANGUAGE='JavaScript' SRC='Lightbox/HoverDivMethods.js'></SCRIPT>
	<script src="sorttable.js"></script>
	<link rel="stylesheet" type="text/css" href="css/ReportsSummary.css" media="screen" />
	<link rel="stylesheet" type="text/css" href="css/ReportsSummary.css" media="print" />
	
</HEAD>
	<BODY ALIGN = CENTER>
	<DIV NAME = 'MAINPAGE' onscroll="sync()">
	<div id='summaryDiv' align='center' valign='middle'
		style='position:absolute;background-color:#ffffff;visibility:hidden; width: 650px;height: 250px; top: 0px; left: 5px; border:5px solid #0F4CB1; z-index:50;overflow : auto; ' >
	</div>
	<div id='pageDiv' CLASS="black_overlay" STYLE='z-index:25;' onClick="closeSummary('TRUE');"></div>
 
	<FORM NAME = 'myForm' method="POST">
	
	<TABLE ALIGN = CENTER width = 700 border = 0 cellpadding = 0 cellspacing = 0>
		<TR><TD CLASS = 'BLANK'>&nbsp;</TD></TR>
				<TABLE ALIGN = CENTER id='t2' width = 700  cellpadding = 1 cellspacing = 1 class = 'sortable'>
				<?php
					echo "<THEAD>";
					echo "<TR>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 15>Region</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 85>BDE</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Master Logs Count</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Inactive Time</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Business Opp Count</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Inactive Time</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Master Logs Count</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Inactive Time</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Business Opp Count</TD>";
						echo "<TD CLASS = 'TBLHEAD' WIDTH = 50>Inactive Time</TD>";
					echo "</TR>";
					echo "</THEAD>";
					echo "<TBODY>";
 
					WHILE (odbc_fetch_row($RESULTS)) {	
 
						echo "<TR bgcolor='#FFFFFF' onMouseOver=this.bgColor='#FFFFAA'; onMouseOut=this.bgColor='#FFFFFF'>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"850\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=1,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'REGION') == '' ? '--' : odbc_result($RESULTS, 'REGION'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"850\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=1,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".odbc_result($RESULTS, 'BDE')."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"850\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=2,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'EXPIRED_ML_COUNT')=='0' ? '&nbsp;' : odbc_result($RESULTS, 'EXPIRED_ML_COUNT'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"850\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=2,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'EXPIRED_ML_AVG') == '' ? '&nbsp;' : odbc_result($RESULTS, 'EXPIRED_ML_AVG'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"850\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=3,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'EXPIRED_OPP_COUNT') == '0' ? '&nbsp;' : odbc_result($RESULTS, 'EXPIRED_OPP_COUNT'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"850\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=3,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'EXPIRED_OPP_AVG') == '' ? '&nbsp;' : odbc_result($RESULTS, 'EXPIRED_OPP_AVG'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"900\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=4,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'INACTIVE_ML_COUNT') == '0' ? '&nbsp;' : odbc_result($RESULTS, 'INACTIVE_ML_COUNT'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"900\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=4,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'INACTIVE_ML_AVG') == '' ? '&nbsp;' : odbc_result($RESULTS, 'INACTIVE_ML_AVG'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"900\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=5,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'INACTIVE_OPP_COUNT') === '0' ? '&nbsp;' : odbc_result($RESULTS, 'INACTIVE_OPP_COUNT'))."</TD>";
							echo "<TD CLASS = 'TEXT' style='cursor:hand;'onClick='viewSummary(\"900\",\"450\",\"LOADING...\",\"".$dirURL."/dcsmsa/mrc/ReportInactiveLeads_byLead.php?OPTION=5,".odbc_result($RESULTS, 'BDE')."\",\"TRUE\");' TITLE='CLICK to view leads' >".(odbc_result($RESULTS, 'INACTIVE_OPP_AVG') == '' ? '&nbsp;' : odbc_result($RESULTS, 'INACTIVE_OPP_AVG'))."</TD>";
						ECHO "</TR>";
					}
					echo "</TBODY>";
				echo "</TABLE>";		
			?>
	</TD></TR></TABLE>
	</FORM>
	</DIV>
 
	</BODY>
</HTML>
 
 
**********************POPUP PAGE**************************************************
 
<?php
 
//**********************CONNECTIONS************************************************************
 
   include 'Standardcode/Connections.php';
 
//Variables from parent form
 
	$Option= $_GET['OPTION'];
	$split = explode(",", $Option);
	$byclick = $split[0];
	$BDE = $split[1];
	
	if ($byclick ==2) {
		$SQLbyClick = " AND EXPIRED_TYPE = 'ML'";
		$Table = "DCSTBL.MRC_EXPIRED_T";
	} elseif ($byclick ==3) {
		$SQLbyClick = " AND EXPIRED_TYPE = 'OPP'";
		$Table = "DCSTBL.MRC_EXPIRED_T";
	} elseif ($byclick ==4) {
		$SQLbyClick = " AND INACTIVE_TYPE = 'ML' AND JFOLLOWUP_DATE IS NULL";
		$Table = "DCSTBL.MRC_INACTIVE_T";
	} elseif ($byclick ==5) {
		$SQLbyClick = " AND INACTIVE_TYPE = 'OPP' AND JFOLLOWUP_DATE IS NULL";
		$Table = "DCSTBL.MRC_INACTIVE_T";
	} 
	
	IF ($byclick == 2 || $byclick == 3) {
		$SQLExpired = "SELECT A.J_SALES_REGION
		, A.JFULL_NAME
		, A.LEAD_COMPANY
		, A.APPROVED_DATE
		, A.INACTIVE_TIME
		, A.FOLLOWUP_DATE
		, B.RN_APPT_ID_STR
		, A.MRC_LEAD_ID
		FROM ".$Table." A
		INNER JOIN
		DCSTBL.MRC_LEADSINATLAS_T B ON A.MRC_LEAD_ID = B.MRC_LEAD_ID
		WHERE A.JFULL_NAME = '".$BDE."' 
		".$SQLbyClick." 	
		WITH UR";
 
		$RESULTS= odbc_exec($DB2Q,$SQLExpired);
	} else {		
		$SQLInactive = "SELECT A.J_SALES_REGION
		, A.JFULL_NAME
		, A.LEAD_COMPANY
		, A.APPROVED_DATE
		, A.INACTIVE_TIME
		, CHAR(DATE(A.JFOLLOWUP_DATE), USA) AS FOLLOWUP_DATE
		, A.LAST_ACTIVITY_DATE
		, A.LAST_ACTIVITY_TYPE
		, A.LAST_ACTIVITY_DESC
		, B.RN_APPT_ID_STR
		, A.MRC_LEAD_ID
		FROM ".$Table." A
		INNER JOIN
		DCSTBL.MRC_LEADSINATLAS_T B ON A.MRC_LEAD_ID = B.MRC_LEAD_ID
		WHERE A.JFULL_NAME = '".$BDE."' 
		".$SQLbyClick." 	
		WITH UR";
 
		$RESULTS= odbc_exec($DB2Q,$SQLInactive);
	}
 
?>
<HTML>
<HEAD>
<script src="sorttable.js"></script>
</HEAD>
<BODY>
		<?php
		echo "<TABLE ALIGN = CENTER NAME = 'tablebylead' ID = 'tablebylead' width = 800 CLASS = 'sortable'>";
				echo "<THEAD>";
				echo "<TR>";
					echo "<TD CLASS = 'TBLHEAD'>Company</TD>";
					echo "<TD CLASS = 'TBLHEAD'>Region</TD>";
					echo "<TD CLASS = 'TBLHEAD'>BDE</TD>";
					echo "<TD CLASS = 'TBLHEAD'>Inactive Time</TD>";
					echo "<TD CLASS = 'TBLHEAD'>Atlas Date</TD>";
					echo "<TD CLASS = 'TBLHEAD'>Followup Date</TD>";
				echo "</TR>";
				echo "</THEAD>";
			echo "<TBODY>";
 
			WHILE (odbc_fetch_row($RESULTS)) {	
 
				echo "<TR bgcolor='#FFFFFF' onMouseOver=this.bgColor='#FFFFAA'; onMouseOut=this.bgColor='#FFFFFF'>";
					echo "<TD CLASS = 'TEXTL'>".(odbc_result($RESULTS, 'LEAD_COMPANY')=='' ? '&nbsp' : odbc_result($RESULTS, 'LEAD_COMPANY'))."</TD>";
					echo "<TD CLASS = 'TEXT'>".(odbc_result($RESULTS, 'J_SALES_REGION')=='' ? '&nbsp' : odbc_result($RESULTS, 'J_SALES_REGION'))."</TD>";
					echo "<TD CLASS = 'TEXT'>".(odbc_result($RESULTS, 'JFULL_NAME')=='' ? '&nbsp' : odbc_result($RESULTS, 'JFULL_NAME'))."</TD>";
					echo "<TD CLASS = 'TEXT'>".(odbc_result($RESULTS, 'INACTIVE_TIME')=='' ? '&nbsp' : odbc_result($RESULTS, 'INACTIVE_TIME'))."</TD>";
					echo "<TD CLASS = 'TEXT'>".(odbc_result($RESULTS, 'APPROVED_DATE')=='' ? '&nbsp' : odbc_result($RESULTS, 'APPROVED_DATE'))."</TD>";
					echo "<TD CLASS = 'TEXT'>".(odbc_result($RESULTS, 'FOLLOWUP_DATE')=='' ? '&nbsp' : odbc_result($RESULTS, 'FOLLOWUP_DATE'))."</TD>";
				ECHO "</TR>";
			}
			echo "</TBODY>";
			echo "</TABLE>";
		
		?>
 
</BODY>
</HTML>

Open in new window

0
Comment
Question by:nicoleheritage
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 24804971
try providing the full url to the javascript file. Perhaps it is not finding it. I removed all the php markup from what you posted and it works (see attached code). If you provide the full path and the problem persists, then inspect the markup generated by your php code to make sure it doesn't "break" the table. In other words, make sure the content you are pulling from the db doesn't have table markup.

On another note, Install Firefox, then click on Tools > Add Ons.

Then search for "Web Developer Toolbar" and install it. Once you install it, restart the browser. Reopen your page and click on Information > Javascript.  If the browser IS able to find your javascript file, you will clearly know because you will see the javascript code. IF you do not see it, then the browser is not able to retrieve it (for whatever reason - wrong url, bad permissions on the file,...)
<HTML>
<HEAD>
<script src="http://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>
</HEAD>
<BODY>
<TABLE ALIGN = CENTER NAME = 'tablebylead' ID = 'tablebylead' width = 800 CLASS = 'sortable'>
                                <THEAD>
                                <TR>
                                        <TD CLASS = 'TBLHEAD'>Company</TD>
                                        <TD CLASS = 'TBLHEAD'>Region</TD>
                                        <TD CLASS = 'TBLHEAD'>BDE</TD>
                                        <TD CLASS = 'TBLHEAD'>Inactive Time</TD>
                                        <TD CLASS = 'TBLHEAD'>Atlas Date</TD>
                                        <TD CLASS = 'TBLHEAD'>Followup Date</TD>
                                </TR>
                                </THEAD>
                        <TBODY>
                                <TR bgcolor='#FFFFFF' onMouseOver=this.bgColor='#FFFFAA'; onMouseOut=this.bgColor='#FFFFFF'>
                                        <TD CLASS = 'TEXTL'>a</TD>
                                        <TD CLASS = 'TEXT'>1</TD>
                                        <TD CLASS = 'TEXT'>s</TD>
                                        <TD CLASS = 'TEXT'>g</TD>
                                        <TD CLASS = 'TEXT'>z</TD>
                                        <TD CLASS = 'TEXT'>3</TD>
                                </TR>
                                <TR bgcolor='#FFFFFF' onMouseOver=this.bgColor='#FFFFAA'; onMouseOut=this.bgColor='#FFFFFF'>
                                        <TD CLASS = 'TEXTL'>b</TD>
                                        <TD CLASS = 'TEXT'>2</TD>
                                        <TD CLASS = 'TEXT'>t</TD>
                                        <TD CLASS = 'TEXT'>h</TD>
                                        <TD CLASS = 'TEXT'>w</TD>
                                        <TD CLASS = 'TEXT'>5</TD>
                                </TR>
                        </TBODY>
                        </TABLE>
</BODY>
</HTML>

Open in new window

0
 

Expert Comment

by:tonybrasunas
ID: 38479775
This doesn't resolve the issue. I've run across the same issue. For some reason sorttable.js does not work inside a lightbox, and I don't know what it is. Could be a javascript conflict issue, but I don't know.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 38480382
Hmm, 3 years on - perhaps new versions of both sortable and lightbox are available
If not, jQuery UI should possibly have working versions of both
0
 

Expert Comment

by:tonybrasunas
ID: 38482654
Indeed, this is the solution. Use the latest version of the script. Obviously.

Thanks mplungjan.

In this case the "newest" version is 2007. The key is using the version by Yoast, who took over the script from Stuart Langridge and made some compatibility tweaks to it. Latest version here works inside lightbox. I was using Langridge's latest version.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

782 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