日期:2014-05-16  浏览次数:20328 次

一个DOM问题,麻烦解决下 谢谢
<form   action= " <%=imgpath%> /budget/zhichubudget/projecttree.do "   method= "post "   name= "model "   id= "XXX ">
<input   type= "hidden "   name= "useArea "   value= " ">
<table   class= "tabletop ">
<tr>
                          <td   class= "tabletop "   align= "right ">
工程类型:
<select   name= "gongchengTypeID "   id= "gongchengTypeID "   onchange= "gcList() ">
<option   value= " ">
            全部
</option>
<option   value= " ">
无工程
</option>
</select>


----------------------
请问我想取得 "全部 "这个字符串用来判断用,怎么用DOM取得啊?谢谢了

------解决方案--------------------
<form action= " <%=imgpath%> /budget/zhichubudget/projecttree.do " method= "post " name= "model " id= "XXX ">
<input type= "hidden " name= "useArea " value= " ">
<table class= "tabletop ">
<tr>
<td class= "tabletop " align= "right ">
工程类型:
<select name= "gongchengTypeID " id= "gongchengTypeID " onchange= "gcList() ">
<option value= " ">
全部
</option>
<option value= " ">
无工程
</option>
</select>
<script type= "text/javascript ">
var wc = document.getElementById( "gongchengTypeID "), os = wc.options, i;
for (i = 0 ; i < os.length ; i ++) {
if (/全部/.test(os[i].innerHTML)) {
alert(i);
}
}
</script>
------解决方案--------------------
<script type= "text/javascript ">
var gcItems = document.getElementById( "gongchengTypeID ").getElementsByTagName( "option ");
alert(gcItems[0].firstChild.nodeValue);
</script>
------解决方案--------------------
<script type= "text/javascript ">
var gcItems = document.getElementById( "gongchengTypeID ");
for(var i=0;i <gcItems.options.length;i++){
if(gcItems.options[i].text== '全部 '){
alert(i);
}
}
</script>