473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

osward
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
26 2297
acoder
16,027 Expert Mod 8TB
Post an example of a table row including the field which contains the URL.
Nov 19 '07 #2
osward
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
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
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
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, 201 views)
Nov 20 '07 #9
acoder
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
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
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
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
16,027 Expert Mod 8TB
Watch those spaces!

Glad you got it working.

Maybe next time we can work on the more advanced solution.
Nov 20 '07 #15
osward
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
16,027 Expert Mod 8TB
Can you post the generated source code?
Nov 20 '07 #17
osward
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, 80 views)
Nov 21 '07 #18
acoder
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
What's generating the end tags?
Nov 22 '07 #23
osward
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
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
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

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

Similar topics

6
by: BlueDragon | last post by:
Grrr! I'm trying to run a script: print 'Declaring cursor' declare cInv cursor forward_only static for select distinct inv.company, inv.contact, inv.address1, inv.city,
1
by: john woo | last post by:
Hi I'm not good at JS, but want to get more about it. I want to use a JSP (the java code just used to get date, the rest are html and javascript), to display a table. the requirement is the...
3
by: I Are Confused | last post by:
I am trying to open Database #2 while in Database #1 and delete a table that is in #2 so that I can copy a table from #1 into #2 - all through a function. My Database #2, as part of the start up,...
6
by: ultraton | last post by:
While trying to print a report from Access the user receives the following error: Cannot open any more databases. Okay Help Does anyone have any ideas about this behavior? Thank you very...
5
by: Silvia | last post by:
Hi I have a listbox in a form which has been set on multiselect simple. If I select some of the items on the list on day1, save and exit, and return on day2, the items I selected on day1 do not...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
14
by: Gary Shell | last post by:
I have five comboboxes each has a item listed populated by hand in the IDE. Each has the text property bound to a text field in the database. When I initially fill the dataset and display the page...
0
by: gm | last post by:
Immediately after generating the Access application from the Source Safe project I get: "-2147467259 Could not use ''; file already in use." If Access database closed and then reopened I get:...
0
by: Salad | last post by:
A97. Split database. Frontend DB1.MDB. Backend DB1BE.MDB. Tables are linked between DB1 and DB2. From my testing, if I open DB1 exclusively using /excl the backend DB1BE is not opened...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.