DIV滚动不工作

时间:2012-12-25 11:17:08

标签: php mysql html

我有一个带有DIV的php文件,其中包含mysql表内容。我还在此页面上有其他链接和信息。

我只想让div内容有一个滚动条,我使用了overflow = scroll;但滚动条不适用于DIV。

需要帮助!

这是我的代码:

<html>
<head>
<title></title>
<style type="text/css">
<!--
body {
    background-color: #D7F0FF;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}

.sty12 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: normal;
    background-color: #FFFFFF;
    }

.sty1 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
}

.style1 {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 24px;
    color: #FFFFFF;
    font-weight: bold;
}

#wrapper { MARGIN: 0px auto; VERTICAL-ALIGN: middle; TEXT-ALIGN: left }

.style3 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #333333;
    }

.style5 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: bold;
    color: #ffffff;
}

.style7 {
    color: #026465;
    font-size: 9px;
}

.toprow {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: bold;
    background-color: #CCCCCC;
    }

-->
</style>

<script type="text/javascript">
function postData(someValueToEvalute)
                    {
                        switch(someValueToEvalute){

                            case "1":{
                                    document.forms[0].action = 'invoiceprint2.php'
                                    break;
                                }
                            case "2":{
                                    document.forms[0].action = 'invoiceprint3.php'
                                    break;
                                }
                            default: { alert('fail');}

                        }
                        document.forms[0].submit();
                    }
</script>
</head>
<body>
<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#026465">
  <tr>
    <td><div align="center"><span class="style1"> PACE LTD <br></span>
<center class="style5">INVOICE PRINTING</center>
<br><br>
<br>

</td>
  </tr>
</table>

<!--------------VALIDATIONS ------------------->

<br>
<br>

<form name="form1" method="post" action="" target="_blank">
<table width='40%' height='39'  border='0' cellpadding='2' cellspacing='0'>
<tr>
<td width=10>&nbsp;</td>
<td class='sty1'><div align='left'>Please select Invoice No. to PRINT: <br>
<br>
You can choose more than one invoice number from the options, by holding CTRL key on your keyboard and select the numbers.</div></td>
<td>
<?php

$dbservertype='mysql';
$servername='localhost';
$dbusername='itec';
$dbpassword='!@#';
$dbname='vga';

////////////////////////////////////////
////// DONOT EDIT BELOW  /////////
///////////////////////////////////////
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////// End of connecting to database ////////



    $result = mysql_query("SELECT Invno FROM INVHDR ORDER BY Invno DESC");
    echo "<select multiple='multiple' size='20' name='invnos[]'>";
    while($nt=mysql_fetch_assoc($result))
    {//Array or records stored in $nt
    echo "<option value=$nt[Invno]>$nt[Invno]</option>";
    /* Option values are added by looping through the array */
    }
    echo "</select>";// Closing of list box

echo "</td>";

?>
</tr>
</table><br>

<div id="Layer1" style="position:absolute; left:465px; top:115px; width:600px; height:600px; overflow:scroll; z-index:1; background-color: #D7F0FF; layer-background-color: #FFFFFF;"> 
<?php
    echo "<table width='540' border='1' cellspacing='0' cellpadding='5' align='left'>";
    echo "<tr>";
    echo "<td width='75' align='center' class='toprow'>Inv Date</td>";
    echo "<td width='75' align='center' class='toprow'>Inv No.</td>";
    echo "<td width='315' align='center' class='toprow'>Customer Name</td>";
    echo "<td width='75' align='center' class='toprow'>Amount</td>";
    echo "</tr>";
$recs=mysql_query("SELECT * FROM INVHDR ORDER BY Invno DESC");
while ($r2=mysql_fetch_assoc($recs))
{
        $invno=$r2['Invno'];    

        $invdat3=$r2['Invdate'];    
        $invdat2=date("Y-m-d", strtotime($invdat3));
        //$invdat2->format('Y-m-d');    
        $date_array = explode( "-", $invdat2 );
        $invdat = sprintf( '%02d/%02d/%4d', $date_array[2], $date_array[1], $date_array[0] );

        $acode=$r2['Ac_code'];
        $amt=$r2['Amount'];

            //--selecting customer name-----------------------------------
            $cus=mysql_query("SELECT Ac_desc FROM ACMAST WHERE Ac_code='$acode'");
            $cus2=mysql_fetch_assoc($cus);
            $acdesc=$cus2['Ac_desc'];

            echo "<tr>";

            echo "<td width='75' align='center' class='sty12'>$invdat</td>";
            echo "<td width='75' align='center' class='sty12'>$invno</td>";
            echo "<td width='315' align='center' class='sty12'>$acdesc</td>";
            echo "<td width='75' align='center' class='sty12'>$amt</td>";

            echo "</tr>";           

    }

    echo "</table><br></div>";
?>

<table width='500' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width=10>&nbsp;</td>

<td align='center'>
<input name="PRINT" type="button" value="PRINT Invoice to Laser Printer!"     onClick='postData("1");' /> &nbsp;&nbsp;&nbsp;  
<input name="PRINT2" type="button" value="PRINT Invoice to Dotmatrix Printer !" onClick='postData("2");'/>

</form>
<br><br><br><br>
<a href='frameinvoice.php' target='_parent'><input name='Add' type='button' value='Add'></a>  &nbsp;&nbsp;  &nbsp;&nbsp; <a href='invoice-edit.php' target='_parent'><input name='Edit' type='button' value='Edit !'></a> &nbsp;&nbsp; <a href='invoice-cancel.php' target='_parent'><input name='Edit' type='button' value='Cancel !'></a> &nbsp;&nbsp; <a href='index.htm' target='_parent'><input name='Close' type='button' value='CLOSE !'></a><br>
</td>

</tr>   
</table>

</body>
</html> 

1 个答案:

答案 0 :(得分:0)

嘿,你的代码工作得很好。你没有足够的数据,所以滚动不工作添加更多的数据,以查看滚动效果或降低div的高度,如下所示。

<div id="Layer1" style="position:absolute; left:465px; top:115px; width:600px; height:100px; overflow:scroll; z-index:1; background-color: #D7F0FF; layer-background-color: #FFFFFF;">