【发布时间】:2016-01-22 09:52:53
【问题描述】:
我有一个代码:
<?php
getPriceListHeader();
function getPriceListDetail($PriceListCode)
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = "SELECT * FROM pricelisdetail where pricelist_code='".$PriceListCode."'";
$results = $readConnection->fetchAll($query);
echo "<table id='tbdata'>
<thead>
<tr>
<th>Price List Code</th>
<th>Price List Name</th>
<th>Effective From</th>
<th>Effective To</th>
</tr>
</thead>
<tbody> ";
foreach ($results as $row)
{
echo "<tr>";
echo "<td> ".$row[entity_id];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
echo "<td> ".$row[sku];
};
echo " </tbody>
</table> ";
}
function getPriceListHeader()
{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$query = 'SELECT * FROM pricelistheader';
$results = $readConnection->fetchAll($query);
echo "
<h2>Price List</h2>
<div>
<h3>Please select Price List</h3>
<div>
<select class='element select large' id='pricelist' name='element_2'>";
foreach ($results as $row)
{
echo '<option value="' . $row[entity_id]. '">' . $row[sku] . '</option>';
}
echo "</select>
</div>
<input type='button' class='button' name='insert' value='Get Data' onclick='getPriceListDetail(pricelist.value)'/>
";
getPriceListDetail('');
}
?>
我有一个下拉列表、一个按钮、一个表格
当我从下拉列表中选择一个值时,然后单击按钮,表格将再次填充数据。有两种方法,getPriceListHeader(): 加载页面时加载数据头,getPriceListDetail :单击按钮时加载数据详细信息。我尝试将事件 getPriceListDetail(value) 放到按钮上,但是当我单击时,什么也没有发生
请帮助我如何做到这一点。
【问题讨论】:
-
if (isset(yourSubmitButton)) { function call here. }。您不能将PHP函数附加到内联JavaScript事件。如果你真的想的话,你也可以使用AJAX。PHP运行服务器端,JavaScript运行客户端。
标签: php html magento events button