我希望在提交的时候,先对目标城市选框进行核对,看是否已经选择。如有值,且值不等于原城市,就提交到下一界面。如果没有选择,或者选择的值是与原值一样,就弹出窗口,要求重选。请各位高手指教。谢谢!
<html>
<head>
<meta http-equiv= "Page-Enter " content= "revealTrans(duration=0.5, transition=8) ">
<meta http-equiv= "Content-Language " content= "zh-cn ">
<META http-equiv=Content-Type content= "text/html; charset=gb2312 ">
<script>
function city_slt_check()
{
var str=document.getElementsByName( 'city_02_slt ').value
if(str.length==0)
{
alert( "请选择转往城市! ");
break;
}
}
</script>
</head>
<body bgcolor= "ffffdf " topmargin= "12 ">
<form id= "form1 " name= "form1 " method= "post " action= "adju_upda_chek.php ">
<font color= 'red ' size= '2 '> <b> 转城市操作确认! </b> </font> <br> <br>
<font color= 'blue '> <b> 您确定对该员工予以转工作城市安排?(登记后,尚需接收城市进行接收操作后才能生效) </b> </font> <br> <br>
卡号:
<br> 姓名:
<br> 原城市:北京
<br> 目标线别:
<select name= "city_02_slt ">
<option value= " "> 请选择目标城市 </option>
<option value= "101 "> 北京 </option>
<option value= "102 "> 上海 </option>
<option value= "103 "> 广州 </option>
</select> (必须选择项) <br> <br>
<input type= 'submit ' name= 'Submit1 ' value= '确认 ' onclick= 'city_slt_check() '>
<input type= 'button ' name= 'Submit2 ' value= '取消 ' onclick= 'history.go(-1) '>
</form>
</body>
</html>
------解决方案--------------------
function city_slt_check()
{
var str=document.getElementsByName( 'city_02_slt ').value;
if(str.length==0||str== "北京 ")
{
alert( "请选择转往城市! ");
return false;
}
else
{
}
}
</script>
------解决方案--------------------
var str=document.getElementsByName( 'city_02_slt ').options[document.getElementsByName( 'city_02_slt ').selectedIndex].value;
------解决方案--------------------
哦 看到了
<script language= "javascript ">
;;;代码
</script>
这都写错了
------解决方案--------------------
<html>
<head>
<meta http-equiv= "Page-Enter " content= "revealTrans(duration=0.5, transition=8) ">
<meta http-equiv= "Content-Language " content= "zh-cn ">
<META http-equiv=Content-Type content= "text/html; charset=gb2312 ">
<script>
function city_slt_check()
{
var str=document.getElementsById( 'city_02_slt ').options[document.getElementsById( 'city_02_slt ').selectedIndex].value;
if(str.length==0 || str== '101 ')
{
alert( "请选择转往城市! ");
return false;
}
return true;
}