cluce Posted September 10, 2007 Share Posted September 10, 2007 I have a table sorting javascrippt code and a navigational menu system for my web page. The problem I am having is I cant get both of them to work at the same time. Is it the way I have the scripts placed in my code?? Or you cant run some scripts at the same time?? Quote Link to comment Share on other sites More sharing options...
cluce Posted September 10, 2007 Author Share Posted September 10, 2007 I know what the problem is. The problem is "The reason for this is that you can only set an “on” event once. If you then try and set the same event on the same element again then the previously set event (including those created using an addEvent variant) will be wiped out. The way to still use an “onload” in your page as well as using Standardista Table Sorting is to simply call addEvent(window, 'load', someFunction); instead of using <body onload='someFunction()'>. " But I am not that good with javascript at all. Can somene please tell me how to fix this? here is my code......... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type='text/javascript' src='common.js'></script> <script type='text/javascript' src='css.js'></script> <script type='text/javascript' src='standardista-table-sorting.js'></script> <script type="text/JavaScript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <?php //connect to database include'db.php'; //get all data from table $sql = "SELECT * from products"; $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli)); $display_block = "<p align = 'center'> <table id='myTable' class='sortable' border = '1' bordercolor = 'black' cellpadding= '0' cellspacing = '0'> <thead> <th id='ItemNumber' scope= 'col' bgcolor = 'orange'>ItemNumber</th> <th id='Manufacturer' scope= 'col' bgcolor = 'orange'>Manufacturer</th> <th id='Category' scope= 'col' bgcolor = 'orange'>Category</th> <th id='Description' scope= 'col' bgcolor = 'orange'>Description</th> <th id='Model' scope= 'col' bgcolor = 'orange'>Model</th> <th id='Quantity' scope= 'col' bgcolor = 'orange'>Quantity</th> <th id='Kw' scope= 'col' bgcolor = 'orange'>Kw</th> <th id='Hours' scope= 'col' bgcolor = 'orange'>Hours</th> <th id='Price' scope= 'col' bgcolor = 'orange'>Price</th> </thead>"; //if authorized, get the values while ($info = mysqli_fetch_array($result)) { $ItemNo = stripslashes($info['Item_No']); $Man = stripslashes($info['Manufacturer']); $Cat = stripslashes($info['Category']); $Des = stripslashes($info['Description']); $Model = stripslashes($info['Model']); $Qty = stripslashes($info['Qty']); $Kw = stripslashes($info['Kw']); $Hours = stripslashes($info['Hours']); $Price = stripslashes($info['Price']); //create display string $display_block .= " <tr> <td>".$ItemNo."</td> <td>".$Man."</td> <td>".$Cat."</td> <td>".$Des."</td> <td>".$Model."</td> <td>".$Qty."</td> <td>".$Kw."</td> <td>".$Hours."</td> <td>".$Price."</td> </tr>"; } $display_block .= "</table></p>"; ?> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- TemplateBeginEditable name="doctitle" --> <title>Product Inventory</title> <!-- TemplateEndEditable --> <style type="text/css"> <!-- body { background-color: #333333; background-image: url(images/bg_tile.gif); } .style8 {font-size: 12px} .style10 {font-family: "Times New Roman", Times, serif; font-size: 14px; font-weight: bold; } a:visited { color: #000000; text-decoration: none; } a:hover { color: #FF6600; background-color: #999999; text-decoration: underline; } a:link { color: #000000; text-decoration: none; } a:active { color: #FF6600; text-decoration: none; } .style12 {font-size: 14px} .style13 {font-family: "Times New Roman", Times, serif; font-size: 18px; } .style14 {color: #FF0000} </style> <body onload="MM_preloadImages('images/btn_home_hover.png','images/btn_products_hover.png','images/btn_p_S_hover.png','images/btn_fabrication_hover.png','images/btn_engineering_hover.png','images/btn_m_d_hover.png','images/btn_m_i_hover.png')"><div align="center"> <table width="1035" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th height="42" colspan="3" align="left" valign="middle" background="images/BG11.jpg" bgcolor="#CCCCCC" scope="col"><div align="center"> <p><img src="images/reagman_L.gif" alt="Reagan logo" width="99" height="98" /><img name="ReaganPower" src="images/Reagan Power.gif" width="581" height="59" border="0" id="ReaganPower" alt="Reagan logo" /><img src="images/reagman_R.gif" alt="Reagan logo" width="99" height="98" /></p> </div> <div align="center"></div></th> </tr> <tr> <th height="23" colspan="3" align="left" valign="middle" bgcolor="#EDA350" scope="col"><div align="center"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image11','','images/btn_home_hover.png',1)"><img src="images/btn_home_active.png" alt="home" name="Image11" width="115" height="23" border="0" id="Image11" onmouseover="MM_showMenu(window.mm_menu_0320083159_0,0,23,null,'Image11')" onmouseout="MM_startTimeout();" /></a><a href="Products.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image12','','images/btn_products_hover.png',1)"><img src="images/btn_products_active.png" alt="products" name="Image12" width="115" height="23" border="0" id="Image12" onmouseover="MM_showMenu(window.mm_menu_0321095832_0,0,23,null,'Image12')" onmouseout="MM_startTimeout();" /></a><a href="Parts_&_Service.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image13','','images/btn_p_S_hover.png',1)"><img src="images/btn_p_S_active.png" alt="parts & services" name="Image13" width="115" height="23" border="0" id="Image13" onmouseover="MM_showMenu(window.mm_menu_0321100130_0,0,23,null,'Image13')" onmouseout="MM_startTimeout();" /></a><a href="Fabrication.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image14','','images/btn_fabrication_hover.png',1)"><img src="images/btn_fabrication_active.png" alt="fabrication" name="Image14" width="115" height="23" border="0" id="Image14" /></a><a href="Engineering.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image17','','images/btn_engineering_hover.png',1)"><img src="images/btn_engineering_active.png" alt="engineering" name="Image17" width="115" height="23" border="0" id="Image17" /></a><a href="http://www.reaganpowermarine.com/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image15','','images/btn_m_d_hover.png',1)"><img src="images/btn_m_d_active.png" alt="marine division" name="Image15" width="115" height="23" border="0" id="Image15" /></a><a href="More_Information.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image16','','images/btn_m_i_hover.png',1)"><img src="images/btn_m_i_active.png" alt="more information" name="Image16" width="115" height="23" border="0" id="Image16" onmouseover="MM_showMenu(window.mm_menu_0321100755_0,0,23,null,'Image16')" onmouseout="MM_startTimeout();" /></a></div></th> </tr> <tr> </tr> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.