1

How to Display the selected value when the option is selected in dropdown menu in phtml without using javascript.here is what i have tried so far!.i am trying this one in 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>
4

2 回答 2

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,
于 2013-06-26T12:23:48.467 回答
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>
于 2013-06-26T11:27:57.467 回答