怎么用iframe来解决此问题
假如一个表单中有三项,第一项为一个下拉框,其中选择下拉框的第一列时,第二个文本框的值只能在给定的数组里取值,第三个文本框的值为默认值.怎么实现 呀
我改了一个HTML文件有点长,大家看一下怎么实现呀,谢谢
<html>
<head>
<meta http-equiv= "content-type " content= "text/html;charset=gb2312 ">
<script language= "JavaScript " type= "text/JavaScript ">
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array( "aa ");
subcat[1]=new Array( "bb ")
onecount=2;
var User_code=document.form1.2.value;//页面所取
function check_user(id){
var User_type=id;//用户类型
if(User_type==a){
var JL_Dep_name= "有限公司 ";
document.all.3.value=JL_Dep_name;
return JL_Dep_name;
var i;
for(i=0;i <onecount;i++){
if (User_code==subcat[i])
break;
}
if(i> =onecount){
alert( "用户名不正确! ");
form1.2.focus();
return false;
}
}
return true;
}
}
</script>
</head>
<body >
<form name= 'form1 ' method= 'post ' onSubmit= "return check_form(); " action= "2.jsp ">
<table border= "0 " width= "100% " align= "center " cellpadding= "2 " cellspacing= "1 " bgcolor= "#A4B6D7 ">
<tr>
<td width= "30% ">
<select name= '1 ' style= "width:97% " onChange= "check_user(document.form1.1.options
[document.form1.1.selectedIndex].value) ">
<option> 请选择
</option>
<option value= 'a '>
监理方
</option>
<option value= 'b '>
建设方
</option>
<option value= 'c '>
承建方
</option>
</select>
</td>
<td width= "30% " align= 'left '>
<input type= 'text ' name= '2 ' style= "width:97% " onblur= "return check_User_code() ">
</td>
<td width= '30% ' align= 'center '>
<input type= 'text ' name= '3 ' style= "width:97% ">
</td>
</tr>
</table>
</form>
</body>
</html>
[解决办法]
<html>
<head>
<meta http-equiv= "content-type " content= "text/html;charset=gb2312 ">
</head>
<body >
<form name= 'form1 ' method= 'post ' onSubmit= "return check_form(); " action= "2.jsp ">
<table border= "0 " width= "100% " align= "center " cellpadding= "2 " cellspacing= "1 " bgcolor= "#A4B6D7 ">
<tr>
<td width= "30% ">
<select name= 'a ' style= "width:97% " onChange= "check_user(this.value) ">
<option> 请选择 </option>
<option value= 'a '> 监理方 </option>
<option value= 'b '> 建设方 </option>
<option value= 'c '> 承建方 </option>
</select>
</td>
<td width= "30% " align= 'left '>
<input type= 'text ' name= 'b ' style= "width:97% " onblur= "return check_User_code() ">
</td>
<td width= '30% ' align= 'center '>
<input type= 'text ' name= 'c ' style= "width:97% ">
</td>
</tr>
</table>
</form>
<script language= "JavaScript " type= "text/JavaScript ">
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array( "aa ");
subcat[1]=new Array( "bb ");
onecount=2;
var User_code=document.form1.a.value;//页面所取
function check_user(id){
var User_type=id;//用户类型
if(User_type== 'a '){
var JL_Dep_name= "有限公司 ";
document.all.c.value=JL_Dep_name;
// return JL_Dep_name;
var i;
for(i=0;i <onecount;i++){
if (User_code==subcat[i])
break;
}
if(i> =onecount){
alert( "用户名不正确! ");
form1.b.focus();
return false;
}
}
return true;
}
</script>
</body>
</html>
[解决办法]
楼主的第二个文本框的值只能在给定的数组里取值,第三个文本框的值为默认值?????????
楼主的意思是:
第二个文本框的值是根据第一个下拉框的值不同而变化吗?
第三个文本框与前面两个无关吗?
那你的
subcat = new Array();
subcat[0] = new Array( "aa ");
subcat[1]=new Array( "bb ")
与这三个框有什么关系呢?
总之我觉得你的程序写得有点乱(仅是个人观点哈),请楼主不要生气,继续努力
[解决办法]
<html>
<head>
<meta http-equiv= "content-type " content= "text/html;charset=gb2312 ">
</head>
<body >
<form name= 'form1 ' method= 'post ' onSubmit= "return check_form(); " action= "2.jsp ">
<table border= "0 " width= "100% " align= "center " cellpadding= "2 " cellspacing= "1 " bgcolor= "#A4B6D7 ">
<tr>
<td width= "30% ">
<select name= 'a ' style= "width:97% " onChange= "check_user(this.value) ">
<option> 请选择 </option>
<option value= 'a '> 监理方 </option>
<option value= 'b '> 建设方 </option>
<option value= 'c '> 承建方 </option>
</select>
</td>
<td width= "30% " align= 'left '>
<input type= 'text ' name= 'b ' style= "width:97% " onblur= "return check_User_code() ">
</td>
<td width= '30% ' align= 'center '>
<input type= 'text ' name= 'c ' style= "width:97% ">
</td>
</tr>
</table>
</form>
<script language= "JavaScript " type= "text/JavaScript ">
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array( "aa ");
subcat[1]=new Array( "bb ");
onecount=2;
var User_code=document.form1.a.value;//页面所取
function check_user(id){
var User_type=id;//用户类型
if(User_type== 'a '){
var JL_Dep_name= "有限公司 ";
document.all.c.value=JL_Dep_name;
// return JL_Dep_name;
var i;
for(i=0;i <onecount;i++){
if (User_code==subcat[i])
break;
}
if(i> =onecount){
alert( "用户名不正确! ");
form1.b.focus();
return false;
}
}
return true;
}
</script>
</body>
</html>