首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

一个DOM有关问题,麻烦解决下 多谢

2012-02-14 
一个DOM问题,麻烦解决下 谢谢formaction %imgpath% /budget/zhichubudget/projecttree.do method

一个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>

热点排行