我在弹出窗口中有下拉菜单,用户可以在其中选择他们的国家。我正在使用隐藏字段通过 php 提交选择,当我点击“提交”按钮时,我得到了选择的国家/地区。有关国家/地区的信息显示在标题中,因此它应该出现在每个页面上,但是当我开始在页面之间浏览时,国家/地区的价值消失了。我怎样才能把它放在每一页上?
<div class="field">
<div class="input-box">
<?php $_countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false); ?>
<?php if (count($_countries) > 0): ?>
<select name="country" id="country" onchange="print(this.value)">
<option value=""> </option>
<?php foreach($_countries as $_country): ?>
<?php if(!in_array($_country['value'], $arrNO)):?>
<option value="<?php echo $_country['value'] ?>" >
<?php echo $_country['label'] ?>
</option>
<?php endif;?>
<?php endforeach; ?>
</select>
<?php endif; ?>
</div>
<form action="" method="post">
<input id="choice" type="hidden" name="fname" value=""/>
<input type="submit" value="OK"/>
</form>
<div id="usWarning"><p><span class="red">NOTE</span>: If you live in <span class="red">Arizona</span>, <span class="red">Iowa</span>, <span class="red">Maryland</span>, <span class="red">Oklahoma</span>, <span class="red">South Dakota</span>, <span class="red">Vermont</span>, <span class="red">Washington</span> or <span class="red">Wisconsin</span>, we are unfortunately not allowed to sell tobacco to you. Its forbidden with online sales of tobacco in these states.</p></div>
</div>
借助 JS 分配的隐藏输入字段的“值”:
function print(value) {
document.getElementById("choice").value=value;
}
谢谢您的帮助。