Solved

Javascript sort on table not working on lightbox popup

Posted on 2009-07-07
5
498 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
5 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

929 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

9 Experts available now in Live!

Get 1:1 Help Now