我有一个表单,其中一个下拉菜单生成 2 个字段。现在的问题是我已经生成了一个字段并尝试获取两个字段,在第一个字段中显示价格,在第二个标签中显示 product_id。我的脚本只是显示价格而不是 ID。由于缺乏知识,我被困住了。我只是需要某人的帮助。
JavaScript:
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' '); }
selbox.options[selbox.options.length] = new Option('100 Directory Submission', '$9.99', '1');
selbox.options[selbox.options.length] = new Option('200 Directory Submission', '$19.99', '2');
selbox.options[selbox.options.length] = new Option('300 Directory Submission','$29.99', '3');
}
document.myform.amount.value="";
document.myform.hidden.value="";
}
HTML:
<select name="opttwo" size="1" onchange="this.form.amount.value=this.value;">
<option value=" " selected="selected">Select any option of the above first</option>
</select>
Amount Payable:<input type="text" readonly="readonly" name="amount" />
Product id:<input type="text" name="hidden" readonly="readonly" />