Images not displayed using javascript onload

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
phphunger
Forum Commoner
Posts: 45
Joined: Tue Aug 11, 2009 11:56 pm

Images not displayed using javascript onload

Post by phphunger »

Hi,

Images are not displayed when the page is loaded. Displays error on page when the page loads.

Code:

Code: Select all

<?php
ob_start();
session_start();
include("includes/dbconfig.php");
$currentdate=date("Y-m-d");
$seladv=mysql_query("select * from ks_weeklyads where status=1");
while($retads=mysql_fetch_array($seladv))
{
    if($currentdate==$retads['enddate'])
    {
        $updateadv=mysql_query("Update ks_weeklyads set status=0 where auto_id='$retads[auto_id]'");
    }
}
//echo $currentdate;
if(!isset($_SESSION['userid']))
{
header("location:index.php");
exit;
}
$limit = 12;
    if($_GET['start']!='') {
        $start = $_GET['start'];
    } else {
        $start = 0;
    }
$filePath = "main.php";
 
?>
<!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>
 
 
<meta http-equiv="Content-Type" content="text/html; cha$et=iso-8859-1"><title>KERALASPICYDEALS.COM</title>
<link href="includes/styles.css" rel="stylesheet" type="text/css">
<style type="text/css">
</style>
<link href="/style.css" rel="stylesheet" type="text/css">
<link href="/includes/style.css" rel="stylesheet" type="text/css" />
<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.laye$&&i<d.laye$.length;i++) 
  x=MM_findObj(n,d.laye$[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>
<link href="includes/style.css" rel="stylesheet" type="text/css" />
</head><body class="body" onload="MM_preloadImages('images/bid_now_over.jpg','images/customer.jpg','images/shop.jpg','images/bank.jpg','images/customer_login_red.jpg','images/shop_login_red.jpg','images/bank_login_red.jpg')">
 
<table align="center" border="0" cellpadding="0" cellspacing="0" width="1003">
  <tbody>
  <tr>
    <td><table align="center" border="0" cellpadding="0" cellspacing="0" width="1003">
      <tbody>
      <?php include("includes/header.php"); ?>
    </tbody></table></td>
  </tr>
  <tr>
    <td><table align="center" border="0" cellpadding="0" cellspacing="0" width="1003">
      <tbody><tr>
        <td colspan="3" height="5"></td>
        </tr>
      <tr>
        <?php include("includes/leftpanel.php"); ?>
        <td align="center" valign="top" width="650"><table width="656" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="11">&nbsp;</td>
            <td width="625"><table align="center" border="0" cellpadding="0" cellspacing="0" width="635">
              <tbody>
                <tr>
                  <td width="10"><?php include("includes/banner.php")?></td>
                </tr>
                <tr>
                  <td height="6"></td>
                </tr>
                <tr>
                  <td><table align="center" border="0" cellpadding="0" cellspacing="0" width="635">
                      <tbody>
                        <tr>
                          <td align="left" valign="top"><img src="images/inner_box_top.jpg" height="20" width="635" /></td>
                        </tr>
                        <tr>
                          <td align="left" valign="top" class="inner_bg"><table width="540" border="0" align="center" cellpadding="0" cellspacing="0">
                              <tr>
                                <td align="center" valign="middle"><img src="images/hotdeal.jpg" width="200" height="17" /></td>
                              </tr>
                              <tr>
                                <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td><table width="540" border="0" align="center" cellpadding="0" cellspacing="0">
                                    <tr>
                                    <?php
                    $sqlhot1=mysql_query("select * from ks_products where hotdeals=1"); 
                    $count=mysql_num_rows($sqlhot1);            
                if($count >0)
                    {
 
                    $sqlhot=mysql_query("select * from ks_products where hotdeals=1 LIMIT $start,$limit");
 
                $i=0;
                while($featuredData=mysql_fetch_array($sqlhot)) {
                
                if($i%4==0) {  
                if($i==0) { 
                ?>
                 <tr>
                 <?php }  else {?> </tr><tr><?php } } ?>
                                      <td width="150" align="left" valign="top"><table width="150" border="0" align="center" cellpadding="0" cellspacing="0">
                                          <tr>
                                            <td align="left" valign="top"><img src="images/product_box-left.gif" width="20" height="20" /></td>
                                            <td width="100%" align="left" valign="top" class="inner-top">&nbsp;</td>
                                            <td width="18" align="right" valign="top"><img src="images/product_box-right.gif" width="20" height="20" /></td>
                                          </tr>
                                          <tr>
                                            <td align="left" valign="top" class="inner-left">&nbsp;</td>
                                            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                  <td colspan="2" align="center" valign="middle">
                                                  <a href="products.php?pid=<?php=$featuredData['product_id']?>" class="nav3"><img src="images/products/featured/<?php=$featuredData['image']?>" width="70" height="62" border="0" /></a>
                                                  </td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="left" class="red_header">&nbsp;</td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="left"><strong class="red_header">Rs</strong><span class="red_header"><?php=$featuredData['product_price']?></span></td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="left">&nbsp;</td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="left" class="body_text"><?php=$featuredData['product_smalldesc']?></td>
                                                </tr>
                                                
                                                <tr>
                                                  <td colspan="2" align="left" valign="middle" class="body_text">&nbsp;</td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="left" valign="middle" class="body_text"><a href="products.php?pid=<?php=$featuredData['product_id']?>" class="nav3">more info..</a></td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="left" valign="middle" class="body_text">&nbsp;</td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="left" valign="middle" class="body_text"><a href="products.html" class="nav3"></a></td>
                                                </tr>
                                                <tr>
                                                  <td colspan="2" align="center" valign="middle" class="body_text"><table align="center" border="0" cellpadding="0" cellspacing="0" width="87">
                                                      <tbody>
                                                        <tr>
                                                          <td align="left" valign="top" width="7"><img src="images/red_butten_left.jpg" height="25" width="7" /></td>
                                                          <td align="center" background="images/red_butten_bg.jpg" valign="middle"><a href="order_product.php?pid=<?php=$featuredData['product_id']?>" class="buttontext">Rs <?php=$featuredData['product_price']?></a></td>
                                                          <td align="left" valign="top" width="7"><img src="images/red_butten_right.jpg" height="25" width="7" /></td>
                                                        </tr>
                                                      </tbody>
                                                  </table></td>
                                                </tr>
                                            </table></td>
                                            <td align="right" valign="top" class="inner-right">&nbsp;</td>
                                          </tr>
                                          <tr>
                                            <td align="left" valign="top"><img src="images/product_box-left_bottem.gif" width="20" height="20" /></td>
                                            <td align="left" valign="top" class="inner-bottem">&nbsp;</td>
                                            <td align="left" valign="top"><img src="images/product_box-right_bottem.gif" width="20" height="20" /></td>
                                          </tr>
                                             <tr>
                                <td height="4"></td>
                              </tr>
                                      </table></td>
                                      <td>&nbsp;</td>
                                      <?php  $i++;  }}?>
                                   
                                </table></td>
                              </tr>
                              <tr>
                                <td height="4"></td>
                              </tr>
                              <tr align="right">
                                <td colspan="5" class="body_text"><?php paginate($start,$limit,$count,$filePath,'');?></td>
                            </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td align="left" valign="top"><img src="images/inner_box_bottem.jpg" height="20" width="635" /></td>
                        </tr>
                      </tbody>
                  </table></td>
                </tr>
              </tbody>
            </table></td>
            <td width="11">&nbsp;</td>
          </tr>
        </table></td>
        <?php include("includes/rightpanel.php"); ?>
        </tr>
    </tbody></table></td>
  </tr>
  <?php include("includes/footer.php"); ?>
</tbody></table>
</body></html>
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Images not displayed using javascript onload

Post by onion2k »

phphunger wrote:Displays error on page when the page loads.
And that error says... what?
phphunger
Forum Commoner
Posts: 45
Joined: Tue Aug 11, 2009 11:56 pm

Re: Images not displayed using javascript onload

Post by phphunger »

The following error displays on the status bar.

Code: Select all

http://localhost/kspicydeals/products.php?pid=<?php=$featuredData['product_id']?>
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Images not displayed using javascript onload

Post by onion2k »

Try writing proper code instead of a shortcut. Use

Code: Select all

<?php echo $featuredData['product_id']; ?>
In my opinion you should never use shortcuts. They make fixing broken code harder than it needs to be.
phphunger
Forum Commoner
Posts: 45
Joined: Tue Aug 11, 2009 11:56 pm

Re: Images not displayed using javascript onload

Post by phphunger »

Thanks a lot onion2k the code is working....thanks for your help...
Post Reply