急!!一个表单,里面的一个下拉框,里面的三种类别,当我选中一种类别时,表单生成数目不同的text(100分)

F

ff_ff

Unregistered / Unconfirmed
GUEST, unregistred user!
下拉框的内空有
A,B,C
当我选A时
表单生成三个text
当我选B时
表单生成四个text
当我选A时
表单生成五个text
 
你不会是要这样的吧?
procedure TForm1.ComboBox1Change(Sender:TObject);
begin
if ComboBox1.Text='A' then
ShowMessage('生成3个')
else
if ComboBox1.Text='B' then
ShowMessage('生成4个')
else
if ComboBox1.Text='C' then
ShowMessage('生成5个')
end;
 
也是问题没有描述清楚,要是象楼上说的那么简单,估计他就不问了。
搂主能不能举个例子说明一下啊,不要这么抽象的描述吧!
 
问题没有说明清楚
这样很难回答你的问题
 
是这样的,在jsp中,
一个表单,有一个下拉框,下拉框有三个值,例如A,B,C
我想选下拉框选择B时,为这个表单增加一个文本框text,
这是我定的代码,怎么没有反应
function addText(value){
var form=document.getElementById("insform");
if(value=="SCL-90测评量表"){
var eInput=document.createElement("input");
eInput.type="text";
form.appendChild(eInput);
}
}
....
....
<select name=mykm id=mynum size=&quot;&quot;
onchange=&quot;addText(This.value)&quot;>
不知为什么选了 SCL-90测评量表 项
没有反应,并没有自动添加文本框
 
具体代码如下:
<%@ page contentType=&quot;text/html;charset=gb2312&quot;
%>
<%@ page import=&quot;java.sql.*&quot;%>
<%@ page import=&quot;java.util.*&quot;%>
<jsp:useBean id=&quot;con&quot;
scope=&quot;session&quot;
class=&quot;db.AccessBean&quot;/>
<link rel=&quot;stylesheet&quot;
type=&quot;text/css&quot;
href=&quot;ndxd/css.css&quot;>
<html>
<center>
插入新题
<hr>
<script language=&quot;JavaScript&quot;>
<!--
function checkSubmit(){
if(document.insform.title.value==&quot;&quot;){
alert(&quot;请输入标题&quot;);
return false;
}
else
if(document.insform.A.value==&quot;&quot;){
alert(&quot;请输入A项&quot;);
return false;
}
else
if(document.insform.Ascore.value==&quot;&quot;){
alert(&quot;请分配分数&quot;);
return false;
}
else
if(document.insform.B.value==&quot;&quot;){
alert(&quot;请输入B项&quot;);
return false;
}
else
if(document.insform.Bscore.value==&quot;&quot;){
alert(&quot;请分配分数&quot;);
return false;
}
else
if(document.insform.C.value==&quot;&quot;){
alert(&quot;请输入C项&quot;);
return false;
}
else
if(document.insform.Cscore.value==&quot;&quot;){
alert(&quot;请分配分数&quot;);
return false;
}
else
if(document.insform.D.value==&quot;&quot;){
alert(&quot;请输入D项&quot;);
return false;
}
else
if(document.insform.Dscore.value==&quot;&quot;){
alert(&quot;请分配分数&quot;);
return false;
}
insform.submit();
}
function addText(value){
var form=document.getElementById(&quot;insform&quot;);
if(value==&quot;SAS测评量表&quot;||value==&quot;SDS测评量表&quot;){
form.removeChild(document.getElementsByName(&quot;E&quot;)[0]);
form.removeChild(document.getElementsByName(&quot;EScore&quot;)[0]);
}
}
-->
</script>
<%
String adminName = (String)session.getAttribute(&quot;AdminName&quot;);
String adminPassword = (String)session.getAttribute(&quot;AdminPassword&quot;);
if(adminName==null||adminPassword==null){
response.sendRedirect(&quot;adminlogin.jsp&quot;);
}
%>
<form name=&quot;insform&quot;
id=&quot;insform&quot;
action=&quot;insques.jsp&quot;
method=&quot;post&quot;
>
<table>
<tr>
<td height=&quot;20&quot;>题目名称</td>
<td><input type=&quot;text&quot;
name=&quot;title&quot;></td>
</tr>
<tr>
<td>
试题种类
</td>
<td height=&quot;22&quot;
colspan=&quot;2&quot;>
<select name=mykm id=mynum size=&quot;&quot;
onchange=&quot;addText(this.value)&quot;
>
<%
request.setCharacterEncoding(&quot;GBK&quot;);
ResultSet rs = con.query(&quot;select distinct mytype from type2&quot;);
if(rs.wasNull()){
out.print(&quot;<script language=javascript> alert('对不起暂无可测评科目!');
window.navigate('index.htm');</script>&quot;);
rs.close();
}else
{
while(rs.next()){

%>

<%
String typename = rs.getString(&quot;mytype&quot;);
// int id = rs.getInt(&quot;id&quot;);
%>
<option id=<%=typename%> value=<%=typename%>><%=typename%></option>
<%
}
rs.close();
}
%>
</select></td>

</tr>
<tr>
<td>A 项:</td>
<td><input type=&quot;text&quot;
name=&quot;A&quot;></td>
</tr>
<tr>
<td>分配分数</td>
<td><input type=&quot;text&quot;
name=&quot;Ascore&quot;
onpropertychange=&quot;
if(//D/.test(value))value=value.replace(//D/g,'')&quot;
></td>
</tr>
<tr>
<td>B 项:</td>
<td><input type=&quot;text&quot;
name=&quot;B&quot;></td>
</tr>
<tr>
<td>分配分数</td>
<td><input type=&quot;text&quot;
name=&quot;Bscore&quot;
onpropertychange=&quot;
if(//D/.test(value))value=value.replace(//D/g,'')&quot;
></td>
</tr>
<tr>
<td>C 项:</td>
<td><input type=&quot;text&quot;
name=&quot;C&quot;></td>
</tr>
<tr>
<td>分配分数</td>
<td><input type=&quot;text&quot;
name=&quot;Cscore&quot;
onpropertychange=&quot;
if(//D/.test(value))value=value.replace(//D/g,'')&quot;></td>
</tr>
<tr>
<td>D 项:</td>
<td><input type=&quot;text&quot;
name=&quot;D&quot;
></td>
</tr>
<tr>
<td>分配分数</td>
<td><input type=&quot;text&quot;
name=&quot;Dscore&quot;
onpropertychange=&quot;
if(//D/.test(value))value=value.replace(//D/g,'')&quot;
></td>
</tr>
<tr>
<td>E 项:</td>
<td><input type=&quot;text&quot;
name=&quot;E&quot;
></td>
</tr>
<tr>
<td>分配分数</td>
<td><input type=&quot;text&quot;
name=&quot;Escore&quot;
onpropertychange=&quot;
if(//D/.test(value))value=value.replace(//D/g,'')&quot;
></td>
</tr>
</table>
<input type = &quot;button&quot;
value = &quot;确定&quot;
onclick=&quot;return checkSubmit()&quot;>
<input type = &quot;reset&quot;
value=&quot;取消&quot;>
</form>
</center>
</html>
欢迎光临
 
ff_ff 我把你的JS稍稍改了一下,没什么问题啊
选几个出几个文本框,检查下是不是你别的地方错了
我的测试:
<form name=&quot;form1&quot;
method=&quot;post&quot;
id=&quot;insform&quot;
action=&quot;&quot;>
<select name=&quot;select&quot;
onChange=&quot;addText(this.value)&quot;>
<option value=&quot;----&quot;>----</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;5&quot;>5</option>
</select>
</form>
<script language=&quot;javascript&quot;>
function addText(value){
for(var i=1;i<=value;i++)
{
var eInput=document.createElement(&quot;input&quot;);
eInput.type=&quot;text&quot;;
form1.appendChild(eInput);
}
}
</script>
 
接受答案了.
 
顶部