HY!我是网络开发的新手,只是陷入了困境。我有一个表单,其中一个下拉菜单生成2个字段。现在问题是我已经生成了一个字段并试图获得另一个字段,但由于缺乏知识,我被困住了。如果有人能
,我只需要一些帮助<form name="myform">
<select name="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="1">Directory Submission</option>
<option value="2">Articale Submission</option>
<option value="3">Social Bookmarking</option>
<option value="4">Blog Commenting</option>
<option value="5">Forum Submission</option>
<option value="6">Link Building</option>
</select>
No. Of Submissions: <select name="opttwo" size="1">
<option value=" " selected="selected">Select any option of the above first</option>
</select>
Amount Payable:
</td>
<td>
<input type="text" name="amount" onchange="document.myform.opttwo.options[document.myform.opttwo.selectedIndex].value;" />
现在我的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',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('100 Directory Submission', '$9.99');
selbox.options[selbox.options.length] = new Option('100 Directory Submission', '$9.99');
selbox.options[selbox.options.length] = new Option('300 Directory Submission','$29.99');
}
// and like this other options will come too.
}
我只是想知道应付金额的领域将如何获得金额。
答案 0 :(得分:0)
你的意思是
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 1; // no need to delete the first option
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('100 Directory Submission', '$9.99');
selbox.options[selbox.options.length] = new Option('100 Directory Submission', '$9.99');
selbox.options[selbox.options.length] = new Option('300 Directory Submission','$29.99');
}
document.myform.amount.value="";
// and like this other options will come too.
}
使用此代码
<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:
</td>
<td>
<input type="text" name="amount" readonly="readonly" />