select框中是这样的给值,我怎么给默认值呀,实际他下拉表框中有,呀 <SCRIPT LANGUAGE=vbscript > Dim d,o ' 创建对象变量。 Set d = CreateObject("Scripting.Dictionary") d.Add " ","全部" <%addfirst x%> dim x:x=<%=x%> dim first:first="<%=first%>" remove x '移除 addo x '增加 sub remove(x)'移除 for each ooo in eval("parent.f.S" & x & ".options") execScript "parent.f.S" & x & ".remove " & ooo.index,"vbs" next end sub sub addo(x) '增加 for each code in d.Keys set o=document.createElement("option") o.text=d.Item(code) o.value=code execScript "parent.f.S" & x & ".add o","vbs" next 'execScript "parent.f.S" & x & ".sele o","vbs" end sub if x <3 and eval("parent.f.S" & x & ".length")<>0 then window.location.href="QDanW.asp?x=" & x & "&first=" & first </SCRIPT>
if replace(formName.selectName.value,chr(32),"")="" or formName.selectName.value="undefined" then
应该是把默认值放上去。比如
<select name="select">
<option value="a" selected>a</option>
<option value="x">x</option>
</select>
select默认值是a
那判断的时候就应该是当值为a的时候弹出提示
if ((document.f.one_dqid.value).length==0 )
{
alert("请选择地区!");
document.f.one_dqid.focus();
document.f.one_dqid.select();
return false;
}
select用你这种方法不行的.
Try..
if(document.f.one_dqid.options[document.f.one_dqid.options.selectedIndex].value=="")
{
alert("请选择地区")
document.f.one_dqid.focus();
//document.f.xx.select(),SELECT没有这种方法.文本可以.
return false;
}demo.htm<script>
function check(obj)
{
if(obj.options[obj.options.selectedIndex].value=="")
{
alert("请选择地区")
obj.focus();
//document.f.xx.select(),SELECT没有这种方法.文本可以.
return false;
}
}
</script>
<select name=sel>
<option value="">地区
<option value="1">1
<option value="2">2
</select>
<input type=button onclick="check(document.all.sel)">
不过我用alert(document.f.one_dqid.optionsdocument.f.one_dqid.options.selectedIndex].value);来显示他的值是,弹出的对话框是一个空值,证明他是为空,但为什么就检测不到,
谈出对话框是空的不意味着""如果是" "你也看不到东西
给个默认值吧
<SCRIPT LANGUAGE=vbscript >
Dim d,o ' 创建对象变量。
Set d = CreateObject("Scripting.Dictionary")
d.Add " ","全部"
<%addfirst x%>
dim x:x=<%=x%>
dim first:first="<%=first%>"
remove x '移除
addo x '增加
sub remove(x)'移除
for each ooo in eval("parent.f.S" & x & ".options")
execScript "parent.f.S" & x & ".remove " & ooo.index,"vbs"
next
end sub
sub addo(x) '增加
for each code in d.Keys
set o=document.createElement("option")
o.text=d.Item(code)
o.value=code
execScript "parent.f.S" & x & ".add o","vbs"
next
'execScript "parent.f.S" & x & ".sele o","vbs"
end sub
if x <3 and eval("parent.f.S" & x & ".length")<>0 then window.location.href="QDanW.asp?x=" & x & "&first=" & first
</SCRIPT>
这个虽然好用,是超级大笨狼的代码,但后续的问题也很多!