By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

How to let a highlighted row open the url from a database table

osward
P: 38
Hello everyone,

I am totally new to javascript, here is my situation:

I had a php document that returns a quered database table and I use a javescript download from the web to highlighed the row of the table. I echoed the script and in the <table> tag I added [PHP]echo "<script type=\"text/javascript\" src=\"/modules/event/lib/tableH.js\"></script>";
echo "<table id=\"listing\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" class=\"calendar\" onMouseOver=\"javascript:trackTableHighlight(event , '#daFAFA');\"
onMouseOut=\"javascript:highlightTableRow(0);\">";[/PHP]That is fine for me so far.

I had a field in my table that send user to another page. What I want to do is when user click on the highlighted row, using that field's url and sends user to that page.

I know that shouldn't be difficult but I have no idea where to start or lookup. Would anyone please set me a direction to accomplish this.

Thanks in advance

Osward
Nov 19 '07 #1
Share this Question
Share on Google+
26 Replies


acoder
Expert Mod 15k+
P: 16,027
Post an example of a table row including the field which contains the URL.
Nov 19 '07 #2

osward
P: 38
Hi,

Following is the code of my table[PHP]echo "<script type=\"text/javascript\" src=\"/modules/event/lib/tableH.js\"></script>";
$bgcolor = "$bgcolor3"; // set alternative row color
echo "<table id=\"listing\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" class=\"calendar\" onMouseOver=\"javascript:trackTableHighlight(event , '#daFAFA');\"
onMouseOut=\"javascript:highlightTableRow(0);\">";
echo "<tr id=\"header\" bgcolor=\"$bgcolor2\">"
."<td align=\"center\" class=\"list\">"._EVENTDATE."</td>"
."<td align=\"center\" class=\"list\">"._CODE."</td>"
."<td align=\"center\" class=\"list\">"._EVENTNAME."</td>"
."<td align=\"center\" class=\"list\">"._EVENTTIME."</td>"
."<td align=\"center\" class=\"list\">"._PLACE."</td>"
."<td align=\"center\" class=\"list\">"._HOST."</td>"
."<td align=\"center\" class=\"list\">"._COST."</td>"
."<td align=\"center\" class=\"list\">"._VACANCY."</td>"
."<td align=\"center\" class=\"list\">"._STATUS."</td>"
."</tr>";
// show data in table with while loop
while ($row = $db->sql_fetchrow($result)) {
if ($bgcolor == "$bgcolor3"){
$bgcolor = "$bgcolor1";
}else{
$bgcolor = "$bgcolor3";
}
$eid = $row['eid'];
$code = $row['code'];
$title = $row['title'];
$date = $row['date'];
$time = $row['time'];
$place = $row['place'];
$cost = $row['cost'];
$host = $row['host'];
$vacancy = $row['vacancy'];
$active = $row['active'];
// Caculate actual available vacancy
$temp = $db->sql_numrows($db->sql_query("SELECT eid FROM ".$prefix."_event_user_temp WHERE eid=$eid"));
$confirm = $db->sql_numrows($db->sql_query("SELECT eid FROM ".$prefix."_event_user WHERE eid=$eid"));
$available = $vacancy-($confirm+$temp);
// display qurey data to table
echo "<tr bgcolor=\"".$bgcolor."\">"
."<td align=\"center\" class=\"list\">$date</td>"
."<td align=\"center\" class=\"list\">$code</td>"
."<td align=\"center\" class=\"list\">$title</td>"
."<td align=\"center\" class=\"list\">$time</td>"
."<td align=\"center\" class=\"list\">$place</td>"
."<td align=\"center\" class=\"list\">$host</td>"
."<td align=\"center\" class=\"list\">$cost</td>"
."<td align=\"center\" class=\"list\">$available</td>";
echo "<td align=\"center\" class=\"list\"><font class=\"content\"><a href=\"/modules.php?name=event&op=join&eid=$eid\"><img src=\"images/join1.gif\" alt=\""._JOINEVENT."\" title=\""._JOINEVENT."\" border=\"0\"></a>";
if ($active == 1) {
$active = "<img src=\"images/active.gif\" alt=\""._EVENTACTIVE."\" title=\""._EVENTACTIVE."\" border=\"0\" width=\"16\" height=\"16\">";
} elseif ($active == 0) {
$active = "<img src=\"images/notactive.gif\" alt=\""._EVENTNOTACTIVE."\" title=\""._EVENTNOTACTIVE."\" border=\"0\">";
}
echo "<font class=\"content\">&nbsp;$active</a> ";
echo "<a href=\"/modules.php?name=event&op=info&eid=$eid\"><img src=\"images/view.gif\" alt=\""._SHOW."\" title=\""._SHOW."\" border=\"0\" width=\"13\" height=\"13\"></a></font</td></tr>";
} // close while loop
echo "</table></center>"[/PHP]at line 54 <a href=\"/modules.php?name=event&op=info&eid=$eid\"> is the link I want to access when I click on the highlighted row.

I think I need to add a function to the tableH.js to make this happen but I don't know how to achieve it.

Any idea?

Below is the tableH.js//
Expand|Select|Wrap|Line Numbers
  1. F. Permadi 2005.
  2. // Highlights table row
  3. // Copyright (C) F. Permadi
  4. // This code is provided "as is" and without warranty of any kind.  Use at your own risk.
  5.  
  6.  
  7.  
  8. // These variables are for saving the original background colors
  9. var savedStates=new Array();
  10. var savedStateCount=0;
  11.  
  12. /////////////////////////////////////////////////////
  13. // This function takes an element as a parameter and 
  14. //   returns an object which contain the saved state
  15. //   of the element's background color.
  16. /////////////////////////////////////////////////////
  17. function saveBackgroundStyle(myElement)
  18. {
  19.   saved=new Object();
  20.   saved.element=myElement;
  21.   saved.className=myElement.className;
  22.   saved.backgroundColor=myElement.style["backgroundColor"];
  23.   return saved;   
  24. }
  25.  
  26. /////////////////////////////////////////////////////
  27. // This function takes an element as a parameter and 
  28. //   returns an object which contain the saved state
  29. //   of the element's background color.
  30. /////////////////////////////////////////////////////
  31. function restoreBackgroundStyle(savedState)
  32. {
  33.   savedState.element.style["backgroundColor"]=savedState.backgroundColor;
  34.   if (savedState.className)
  35.   {
  36.     savedState.element.className=savedState.className;    
  37.   }
  38. }
  39.  
  40. /////////////////////////////////////////////////////
  41. // This function is used by highlightTableRow() to find table cells (TD) node
  42. /////////////////////////////////////////////////////
  43. function findNode(startingNode, tagName)
  44. {
  45.   // on Firefox, the TD node might not be the firstChild node of the TR node
  46.   myElement=startingNode;
  47.   var i=0;
  48.   while (myElement && (!myElement.tagName || (myElement.tagName && myElement.tagName!=tagName)))
  49.   {
  50.     myElement=startingNode.childNodes[i];
  51.     i++;
  52.   }  
  53.   if (myElement && myElement.tagName && myElement.tagName==tagName)
  54.   {
  55.     return myElement;
  56.   }
  57.   // on IE, the TD node might be the firstChild node of the TR node  
  58.   else if (startingNode.firstChild)
  59.     return findNode(startingNode.firstChild, tagName);
  60.   return 0;
  61. }
  62.  
  63. /////////////////////////////////////////////////////
  64. // Highlight table row.
  65. // newElement could be any element nested inside the table
  66. // highlightColor is the color of the highlight
  67. /////////////////////////////////////////////////////
  68. function highlightTableRow(myElement, highlightColor)
  69. {
  70.   var i=0;
  71.   // Restore color of the previously highlighted row
  72.   for (i; i<savedStateCount; i++)
  73.   {
  74.     restoreBackgroundStyle(savedStates[i]);          
  75.   }
  76.   savedStateCount=0;
  77.  
  78.   // To get the node to the row (ie: the <TR> element), 
  79.   // we need to traverse the parent nodes until we get a row element (TR)
  80.   // Netscape has a weird node (if the mouse is over a text object, then there's no tagName
  81.   while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
  82.   {
  83.     myElement=myElement.parentNode;
  84.   }
  85.  
  86.   // If you don't want a particular row to be highlighted, set it's id to "header"
  87.   // If you don't want a particular row to be highlighted, set it's id to "header"
  88.   if (!myElement || (myElement && myElement.id && myElement.id=="header") )
  89.     return;
  90.  
  91.   // Highlight every cell on the row
  92.   if (myElement)
  93.   {
  94.     var tableRow=myElement;
  95.  
  96.     // Save the backgroundColor style OR the style class of the row (if defined)
  97.     if (tableRow)
  98.     {
  99.       savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
  100.       savedStateCount++;
  101.     }
  102.  
  103.     // myElement is a <TR>, then find the first TD
  104.     var tableCell=findNode(myElement, "TD");    
  105.  
  106.     var i=0;
  107.     // Loop through every sibling (a sibling of a cell should be a cell)
  108.     // We then highlight every siblings
  109.     while (tableCell)
  110.     {
  111.       // Make sure it's actually a cell (a TD)
  112.       if (tableCell.tagName=="TD")
  113.       {
  114.         // If no style has been assigned, assign it, otherwise Netscape will 
  115.         // behave weird.
  116.         if (!tableCell.style)
  117.         {
  118.           tableCell.style={};
  119.         }
  120.         else
  121.         {
  122.           savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
  123.           savedStateCount++;
  124.         }
  125.         // Assign the highlight color
  126.         tableCell.style["backgroundColor"]=highlightColor;
  127.  
  128.         // Optional: alter cursor
  129.         tableCell.style.cursor='default';
  130.         i++;
  131.       }
  132.       // Go to the next cell in the row
  133.       tableCell=tableCell.nextSibling;
  134.     }
  135.   }
  136. }
  137.  
  138. /////////////////////////////////////////////////////
  139. // This function is to be assigned to a <table> mouse event handler.
  140. // If the element that fired the event is within a table row,
  141. //   this function will highlight the row.
  142. /////////////////////////////////////////////////////
  143. function trackTableHighlight(mEvent, highlightColor)
  144. {
  145.   if (!mEvent)
  146.     mEvent=window.event;
  147.  
  148.   // Internet Explorer
  149.   if (mEvent.srcElement)
  150.   {
  151.     highlightTableRow( mEvent.srcElement, highlightColor);
  152.   }
  153.   // Netscape and Firefox
  154.   else if (mEvent.target)
  155.   {
  156.     highlightTableRow( mEvent.target, highlightColor);        
  157.   }
  158. }
  159.  
  160. /////////////////////////////////////////////////////
  161. // Highlight table row.
  162. // newElement could be any element nested inside the table
  163. // highlightColor is the color of the highlight
  164. /////////////////////////////////////////////////////
  165. function highlightTableRowVersionA(myElement, highlightColor)
  166. {
  167.   var i=0;
  168.   // Restore color of the previously highlighted row
  169.   for (i; i<savedStateCount; i++)
  170.   {
  171.     restoreBackgroundStyle(savedStates[i]);          
  172.   }
  173.   savedStateCount=0;
  174.  
  175.   // If you don't want a particular row to be highlighted, set it's id to "header"
  176.   if (!myElement || (myElement && myElement.id && myElement.id=="header") )
  177.     return;
  178.  
  179.   // Highlight every cell on the row
  180.   if (myElement)
  181.   {
  182.     var tableRow=myElement;
  183.  
  184.     // Save the backgroundColor style OR the style class of the row (if defined)
  185.     if (tableRow)
  186.     {
  187.       savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
  188.       savedStateCount++;
  189.     }
  190.  
  191.     // myElement is a <TR>, then find the first TD
  192.     var tableCell=findNode(myElement, "TD");    
  193.  
  194.     var i=0;
  195.     // Loop through every sibling (a sibling of a cell should be a cell)
  196.     // We then highlight every siblings
  197.     while (tableCell)
  198.     {
  199.       // Make sure it's actually a cell (a TD)
  200.       if (tableCell.tagName=="TD")
  201.       {
  202.         // If no style has been assigned, assign it, otherwise Netscape will 
  203.         // behave weird.
  204.         if (!tableCell.style)
  205.         {
  206.           tableCell.style={};
  207.         }
  208.         else
  209.         {
  210.           savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
  211.           savedStateCount++;
  212.         }
  213.         // Assign the highlight color
  214.         tableCell.style["backgroundColor"]=highlightColor;
  215.  
  216.         // Optional: alter cursor
  217.         tableCell.style.cursor='default';
  218.         i++;
  219.       }
  220.       // Go to the next cell in the row
  221.       tableCell=tableCell.nextSibling;
  222.     }
  223.   }
  224. }
Regards,
Osward
Nov 19 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Since you're using inline event handlers anyway, just add an onclick to the last table cell (td) in each row, e.g. onclick="gotoURL(this)".

Then in the function, just go to the URL in question (it seems as if there are two links in the td cell and we want the second one):
Expand|Select|Wrap|Line Numbers
  1. function gotoURL(td) {
  2. var link = td.getElementsByTagName("a")[1];
  3. window.location.href = link.href;
  4. }
Nov 19 '07 #4

osward
P: 38
Since you're using inline event handlers anyway, just add an onclick to the last table cell (td) in each row, e.g. onclick="gotoURL(this)".

Then in the function, just go to the URL in question (it seems as if there are two links in the td cell and we want the second one):
Expand|Select|Wrap|Line Numbers
  1. function gotoURL(td) {
  2. var link = td.getElementsByTagName("a")[1];
  3. window.location.href = link.href;
  4. }
Hi acoder,

Thanks for the help, I put the function in the tableH.js and put the onclick="gotoURL(this)" inside the <table> tag. It works, but only for the first row of the table. No matter which row I click, it returns the same link as the first row.

I had tried to put the onclick="gotoURL(this) inside the <table> tag and the <td> tag that contains the link but only inside the <table> tag work as described above

Please help

Regards,
Osward
Nov 20 '07 #5

acoder
Expert Mod 15k+
P: 16,027
That's because you attached it to the table tag and not each row.

If you are going to attach it to the table tag, then you will need to find the row in question using something similar to trackTableHighlight, then find the TR node using code similar to the one found in hightlightTableRow:
Expand|Select|Wrap|Line Numbers
  1. while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
  2.   {
  3.     myElement=myElement.parentNode;
  4.   }
Once you have the correct row, you can find the second link and change the page location.
Nov 20 '07 #6

osward
P: 38
That's because you attached it to the table tag and not each row.

If you are going to attach it to the table tag, then you will need to find the row in question using something similar to trackTableHighlight, then find the TR node using code similar to the one found in hightlightTableRow:
Expand|Select|Wrap|Line Numbers
  1. while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
  2.   {
  3.     myElement=myElement.parentNode;
  4.   }
Once you have the correct row, you can find the second link and change the page location.
Hi, acoder
I had tried and place the onclick at the table <tr> tag which is line 38 of my posted php script but it returns an script error at the browser and also it display < a href="/modules.php?name=event&op=info&eid=355"> before the link icon and also the icon's link is disable.

Think have to do it the hard way like you said. I had spent hours trying to make sense of the two function that I could make use of but yet couldn't figure out exactly how. Does it mean the gotoURL function needs another mEvent variable beside the td?

The following is the function I assemby but doesn't work
Expand|Select|Wrap|Line Numbers
  1. function gotoURL(myElement, highlightColor, td)
  2. {
  3.     if (!yElement)
  4.     myElement=window.event;
  5.  
  6.   // Internet Explorer
  7.   if (myElement.srcElement)
  8.   {
  9.     highlightTableRow( myElement.srcElement, highlightColor);
  10.   }
  11.   // Netscape and Firefox
  12.   else if (myElement.target)
  13.   {
  14.     highlightTableRow( myElement.target, highlightColor);        
  15.   }
  16.   while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
  17.   {
  18.     myElement=myElement.parentNode;
  19.   }
  20.   var tableCell=findNode(myElement, "TD");    
  21.  
  22.     var i=0;
  23.     // Loop through every sibling (a sibling of a cell should be a cell)
  24.     // We then highlight every siblings
  25.     while (tableCell)
  26.     {
  27.       // Make sure it's actually a cell (a TD)
  28.       if (tableCell.tagName=="TD")
  29.       {
  30.         var link = td.getElementsByTagName("a")[1];
  31.         window.location.href = link.href;
  32.         tableCell.style.cursor='default';
  33.         i++;
  34.       }
  35.       // Go to the next cell in the row
  36.       tableCell=tableCell.nextSibling;
  37.     }
  38. }
If at all possible, could you assemby the function for me. I understand this is a good way of learning javascript but I really need it badly


Thanks in advance
Regards,
Osward
Nov 20 '07 #7

acoder
Expert Mod 15k+
P: 16,027
Hi, acoder
I had tried and place the onclick at the table <tr> tag which is line 38 of my posted php script but it returns an script error at the browser and also it display < a href="/modules.php?name=event&op=info&eid=355"> before the link icon and also the icon's link is disable.
Let's try the easy way first. On line 38, try:
[PHP]echo "<tr onclick=\"gotoURL(this);\" bgcolor=\"".$bgcolor."\">"[/PHP]
Nov 20 '07 #8

osward
P: 38
Let's try the easy way first. On line 38, try:
[PHP]echo "<tr onclick=\"gotoURL(this);\" bgcolor=\"".$bgcolor."\">"[/PHP]
Doesn't work, script error. Also the field where I put the 2 links show the url I want the function to access but the orginal link gone

One additional question, how can I use the function within the same javascript?
I know how to do it in php but have no idea in javascript

I attached the sceen of the table for your reference
Attached Images
File Type: jpg screen.jpg (20.0 KB, 163 views)
Nov 20 '07 #9

acoder
Expert Mod 15k+
P: 16,027
Doesn't work, script error. Also the field where I put the 2 links show the url I want the function to access but the orginal link gone

One additional question, how can I use the function within the same javascript?
I know how to do it in php but have no idea in javascript
I just tried a quick test and it works.

Can you show your updated code? It must be a misplaced quote.

By "within the same javascript", do you mean in the JavaScript file?
Nov 20 '07 #10

osward
P: 38
I just tried a quick test and it works.

Can you show your updated code? It must be a misplaced quote.

By "within the same javascript", do you mean in the JavaScript file?
[PHP]echo "<tr onclick=\"gotoURL(this);\" bgcolor=\"".$bgcolor."\">"
."<td align=\"center\" class=\"list\">$date</td>"
."<td align=\"center\" class=\"list\">$code</td>"
."<td align=\"center\" class=\"list\">$title</td>"
."<td align=\"center\" class=\"list\">$time</td>"
."<td align=\"center\" class=\"list\">$place</td>"
."<td align=\"center\" class=\"list\">$host</td>"
."<td align=\"center\" class=\"list\">$cost</td>"
."<td align=\"center\" class=\"list\">$available</td>";[/PHP]
This is how I put the gotoURL(this), I also enclosed a screen shot in my last post

Yeah, I mean within the same javascript, how can I use or call other function?
Nov 20 '07 #11

acoder
Expert Mod 15k+
P: 16,027
What about the rest of the code (from lines 47-54 from previous code)?

If the link text is showing up, that means that the quotes are not in the right places and there aren't two links, hence the script error.
Nov 20 '07 #12

osward
P: 38
What about the rest of the code (from lines 47-54 from previous code)?

If the link text is showing up, that means that the quotes are not in the right places and there aren't two links, hence the script error.
Here is the latest version of the code
[PHP]echo "<script type=\"text/javascript\" src=\"/modules/event/lib/tableH.js\"></script>";
$bgcolor = "$bgcolor3"; // set alternative row color
echo "<table id=\"listing\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" class=\"calendar\" onMouseOver=\"javascript:trackTableHighlight(event , '#daFAFA');\"
onMouseOut=\"javascript:highlightTableRow(0);\" onclick=\"javascript:gotoURL(event, '#daFAFA', 'this');\">";
echo "<tr id=\"header\" bgcolor=\"$bgcolor2\">"
."<td align=\"center\" class=\"list\">"._EVENTDATE."</td>"
//."<td align=\"center\" class=\"list\"><a href=\"/modules.php?name=event&order=A_date\"><img src=\"images/asc.gif\" alt=\""._SORTASC."\" title=\""._SORTASC."\" border=\"0\"></a>&nbsp;"._EVENTDATE."&nbsp;<a href=\"/modules.php?name=event&order=D_date\"><img src=\"images/desc.gif\" alt=\""._SORTDESC."\" title=\""._SORTDESC."\" border=\"0\"</a></td>"
."<td align=\"center\" class=\"list\">"._CODE."</td>"
."<td align=\"center\" class=\"list\">"._EVENTNAME."</td>"
."<td align=\"center\" class=\"list\">"._EVENTTIME."</td>"
."<td align=\"center\" class=\"list\">"._PLACE."</td>"
//."<td align=\"center\" class=\"list\"><a href=\"/modules.php?name=event&order=A_place\"><img src=\"images/asc.gif\" alt=\""._SORTASC."\" title=\""._SORTASC."\" border=\"0\"></a>&nbsp;"._PLACE."&nbsp;<a href=\"/modules.php?name=event&order=D_place\"><img src=\"images/desc.gif\" alt=\""._SORTDESC."\" title=\""._SORTDESC."\" border=\"0\"></a></td>"
."<td align=\"center\" class=\"list\">"._HOST."</td>"
."<td align=\"center\" class=\"list\">"._COST."</td>"
."<td align=\"center\" class=\"list\">"._VACANCY."</td>"
."<td align=\"center\" class=\"list\">"._STATUS."</td>"
."</tr>";
// show data in table with while loop
while ($row = $db->sql_fetchrow($result)) {
if ($bgcolor == "$bgcolor3"){
$bgcolor = "$bgcolor1";
}else{
$bgcolor = "$bgcolor3";
}
$eid = $row['eid'];
$code = $row['code'];
$title = $row['title'];
$date = $row['date'];
$time = $row['time'];
$place = $row['place'];
$cost = $row['cost'];
$host = $row['host'];
$vacancy = $row['vacancy'];
$active = $row['active'];
// Caculate actual available vacancy
$temp = $db->sql_numrows($db->sql_query("SELECT eid FROM ".$prefix."_event_user_temp WHERE eid=$eid"));
$confirm = $db->sql_numrows($db->sql_query("SELECT eid FROM ".$prefix."_event_user WHERE eid=$eid"));
$available = $vacancy-($confirm+$temp);
// display qurey data to table
echo "<tr onclick=\"gotoURL(this);\" bgcolor=\"".$bgcolor."\">"
."<td align=\"center\" class=\"list\">$date</td>"
."<td align=\"center\" class=\"list\">$code</td>"
."<td align=\"center\" class=\"list\">$title</td>"
."<td align=\"center\" class=\"list\">$time</td>"
."<td align=\"center\" class=\"list\">$place</td>"
."<td align=\"center\" class=\"list\">$host</td>"
."<td align=\"center\" class=\"list\">$cost</td>"
."<td align=\"center\" class=\"list\">$available</td>";
echo "<td align=\"center\" class=\"list\"><font class=\"content\"><a href=\"/modules.php?name=event&op=join&eid=$eid\"><img src=\"images/join1.gif\" alt=\""._JOINEVENT."\" title=\""._JOINEVENT."\" border=\"0\"></a>";
if ($active == 1) {
$active = "<img src=\"images/active.gif\" alt=\""._EVENTACTIVE."\" title=\""._EVENTACTIVE."\" border=\"0\" width=\"16\" height=\"16\">";
} elseif ($active == 0) {
$active = "<img src=\"images/notactive.gif\" alt=\""._EVENTNOTACTIVE."\" title=\""._EVENTNOTACTIVE."\" border=\"0\">";
}
echo "<font class=\"content\">&nbsp;$active</a> ";
echo "< a href=\"/modules.php?name=event&op=info&eid=$eid\"><img src=\"images/view.gif\" alt=\""._SHOW."\" title=\""._SHOW."\" border=\"0\" width=\"13\" height=\"13\"></a></font</td></tr>";
} // close while loop
echo "</table></center>"
."<br><br>";[/PHP]One remarks, beside of the screen shot I post, the orginal highlight still works

Below is the gotoURL part in the javascript
Expand|Select|Wrap|Line Numbers
  1. function gotoURL(td)
  2. {
  3.   var link = td.getElementsByTagName("a")[1];
  4.   window.location.href = link.href;
  5. }
Regards,
Osward
Nov 20 '07 #13

osward
P: 38
Hi, acoder

I found where the problem lies, there is a extra space in the second link, when I remove this space and put the onclick="gotoURL(this) within the <tr> tag and it works now.

Thanks for remind me checking the place I overlook

Regards,
Osward
Nov 20 '07 #14

acoder
Expert Mod 15k+
P: 16,027
Watch those spaces!

Glad you got it working.

Maybe next time we can work on the more advanced solution.
Nov 20 '07 #15

osward
P: 38
Hi acoder,

The script behaves pretty weird, it work and when I close the browser and reopen it agin, It said script error. When I take away the gotoURL function, it work again.

Think we haven't really solved the problem.

Any suggestion?

Regards

Osward
Nov 20 '07 #16

acoder
Expert Mod 15k+
P: 16,027
Can you post the generated source code?
Nov 20 '07 #17

osward
P: 38
Can you post the generated source code?
I enclosed the source.txt from my browser for your reference. It's a huge file I can't post it here

Regards,
Osward
Attached Files
File Type: zip source.zip (16.1 KB, 51 views)
Nov 21 '07 #18

acoder
Expert Mod 15k+
P: 16,027
I noticed that your table appears after the closing BODY and HTML tags!

I haven't tested it otherwise, but you may want to validate your page.
Nov 21 '07 #19

osward
P: 38
I noticed that your table appears after the closing BODY and HTML tags!

I haven't tested it otherwise, but you may want to validate your page.
Hi acoder,

I notice that as well, this is the calender class that generate the html tag. I am not sure how or should I go into the class file and remove that

Any thoughts?

Regards,
Osward
Nov 21 '07 #20

acoder
Expert Mod 15k+
P: 16,027
Try getting this working on its own and then add the calendar class afterwards, i.e. make a simpler version with only the table.
Nov 21 '07 #21

osward
P: 38
Try getting this working on its own and then add the calendar class afterwards, i.e. make a simpler version with only the table.
Hi acoder,

This is exactly what I am trying to do, I've got a test script with just the table. However, it still carries 2 pair of end tags. I don't think the problem is from the calendar class. Maybe I have to put on a default theme and see what happens but this is really a pain though

I will post my finding hopefully soon

Regards,
Osward
Nov 22 '07 #22

acoder
Expert Mod 15k+
P: 16,027
What's generating the end tags?
Nov 22 '07 #23

osward
P: 38
I finally find out which section of my code in the php document makes additional pair of end tags. It's not the calendar class but the paging class.

After commented out this class, everything is fine now but I wonder how this class would make such a mess
Nov 22 '07 #24

acoder
Expert Mod 15k+
P: 16,027
Glad you got it working.
After commented out this class, everything is fine now but I wonder how this class would make such a mess
I think you should ask that in the PHP forum. Good luck!
Nov 22 '07 #25

osward
P: 38
I downloaded the class form phpclasses.org and they don't have forum for their classes.

Anyhow, thanks for your paient and time to help me make it work

Regards,

Osward
Nov 22 '07 #26

acoder
Expert Mod 15k+
P: 16,027
I downloaded the class form phpclasses.org and they don't have forum for their classes.
If you try the PHP forum here, the experts there might be able to help you.
Nov 22 '07 #27

Post your reply

Sign in to post your reply or Sign up for a free account.