0
我在网络开发新的,我试图寻找从互联网上的任何资源,但我仍然无法找出我的问题......无法创建输入文本框时,选项被选中
=>读文本文件,并生成选项... 我test.jsp的页面
<tr>
<td>Select test : </td>
<td><select id="testname" name="testname" onchange="makeBox()">
while ((src = test.readLine()) != null){
param = "";
temp =src.split(":");
tempsize =temp.length;
if ((tempsize >2)){
int i;
for (i=2; tempsize>i ; i++){
if((temp[i].equals("null"))){
param = "";
}
else if ((i ==2) && (temp[i] != "null")){
param = temp[i];
}
else if ((i > 2)){
param = param + "," + temp[i];
}
}
}
%>
<option value="<%=param%>" name="<%=temp[0]%>"><%=temp[0]%></option>
<%
}
test.close();
%>
</select></td>
</tr>
当用户选择这些选项,JavaScript的将产生的inputText箱对应的参数之一...(参数个数由每个测试不同)
Ex。Ex。比方说
<option value="size,height,weight" name=apple>apple</option>
被选中。然后我想我的页面显示3个文本框状....
<td> Enter size: </td>
<td><input type="text" id="size" name="size"></td>
<td> Enter height: </td>
<td><input type="text" id="height" name="height"></td>
<td> Enter wieght: </td>
<td><input type="text" id="weight" name="weight"></td>
我尝试:
<script type="text/javascript">
function makeBox() {
var selected = document.getElementById('batchname');
for (var i=1, n=selected.options.length;i<n;i++){
if (selected.options[i].value){
var a = "<input type = 'text' name = '" + selected.options[i].value + "' id = '" + selected.options[i].value + "'>";
document.getElementById("inputBox").innerHTML = a;
}
}
};
</script>
我是从读
文本文件:
Apple:A.B.C.D:size:colour
Banana:G.C.D.E:length
Pear:L.D.E.F:shape:weight:color
Orange:E.C.A.W:density:length:color:weight
Melon:E.P.D.A // no param
没有按^什么都不做... 我从选择框中发送多个值以创建多个输入框,我从根本上是错误的? 如果有更好的方法,请给我建议...... :) 感谢您的帮助!