我是新來的。我創建了一個表格,可以顯示數據庫中的數據,並創建另外1個表格來顯示要選擇的數據。但問題是,如果我們只選擇少量數據,它不會是一個問題。但是如果選擇超過100個數據,可能會導致佈局問題。如何製作滾動條?
,這我的代碼...
<script type="text/javascript">
function List(){
var selectedProduct = "";
var product = document.getElementById('product');
var output ="";
var k = 0;
var name = new Array;
var model = new Array;
var unitprice = new Array;
<?php foreach ($productPrices as $price): ?>
name[k] = "<?php echo $price['Product']['txtname']; ?>";
model[k] = "<?php echo $price['Product']['txtmodel']; ?>";
k++;
<?php endforeach; ?>
k=0;
for (var i = 0; i < product.length; i++) {
k = product.options[i].value;
if (product.options[i].selected) {
output += '<tr>'+
'<td style="border-right: 0px; width:270px; text-align:center" id="ProductProduct'+k+'" name="data[Product][Product]['+k+']">'+name[i]+'</td>'+
'<td style="border-right: 0px; width:100px; text-align:left" id="ProductProduct'+k+'" name="data[Product][Product]['+k+']">'+model[i]+'</td>'+
'</tr>';
}
}
output = '<table style="width:500px; border: 0px;">'+output+'</table>';
document.getElementById('productTable').innerHTML = output;
}
</script>
<table cellpadding="0" cellspacing="0" style="width:100%">
<caption><div align="left">Peoduct Selection</div></caption>
<tr>
<th style="width:25%"><font><div align="left">Select Product :</div></font>
<?php echo $form->input('Product',array(
'label' => 'Select Products',
'options' => $products,
'id'=>'product',
'style'=>'width:250px;height:100px',
'selected' => $html->value('Product.Product'),
'onchange'=>'List();')); ?> </th>
<th ><table>
<tr>
<th style="width:400px"><div align="center">Product Name</div></th>
<th style="width:250px"><div align="center">Product Model</div></th>
</tr>
<tr>
<td colspan="4" ><span id="productTable"></td>
</tr>
</table></th>
</tr>
</table>
誰能幫助我解決這個問題? thx ..
你爲什麼改變我的retag?這個問題與php無關,而是與你的佈局有關,因此,它是一個HTML/CSS問題。 – fresskoma 2009-11-11 09:24:17
@ x3ro - 我在猜測,但他可能是錯誤的,他在編輯提交時已經在編輯它。 – 2009-11-11 09:26:49