如何在不使用javascript的情况下在phtml的下拉菜单中选择选项时显示所选值。这是我到目前为止所尝试的内容!。我正在尝试使用magento
<form action="<?php echo $this->getUrl('customer/products/simpleproduct') ?>" enctype="multipart/form-data" method="post" id="form-customer-product-new">
<table class="tablepostion">
<tr>
<td>
<select id="sizeoption">
<option value="1">Small</option>
<option value="2">Medium</option>
<option value="3">Large</option>
</select>
<?php
$a = $_POST['sizeoption'];
echo $a;
?>
</td>
</tr>
</table>
答案 0 :(得分:3)
You need to add name of your dropdown.
<select name="mysize" id="sizeoption">
<option value="Small">Small</option>
<option value="Medium">Medium</option>
<option value="Large">Large</option>
</select>
<?php
$a = $_REQUEST['mysize'];
echo $a;
?>
Thanks,
答案 1 :(得分:1)
试试这个
<?php $a = $_POST['sizeoption']; ?>
<table class="tablepostion">
<tr>
<td>
<select id="sizeoption">
<option <?php echo ($a ==1)?'selected="selected"' : '' ?> value="1">Small</option>
<option <?php echo ($a ==2)?'selected="selected"' : '' ?> value="2">Medium</option>
<option <?php echo ($a ==3)?'selected="selected"' : '' ?> value="3">Large</option>
</select>
</td>
</tr>
</table>