$mName要的是select控件中的text值,不是value值

解决方案 »

  1.   

    selhtml只可能获得当前select的选中值。
    如果你想取得所有的值,最好换成checkbox或者支持多选的下拉框。如果想取得目前所示select的所有值,可以在javascript遍历select然后以字符串的形式将值传过去。
      

  2.   

    <script>
    var result = new Array();
    function getAllItemText(objSelect) {        
        for (var i = 0; i < objSelect.options.length; i++) {        
    result[i] = objSelect.options[i].text;
    }        
        return result;
    }function check(fm){
    fm.selname.value = getAllItemText(fm.sel);
    }
    </script><form name=form1 method=get action='b.html' onsubmit="return check(this)">
    <select name=sel>
    <option value=1>11</option>
    <option value=2>22</option>
    <option value=3>33</option>
    </select>
    <input name=selname type=hidden value=''>
    <input name=submit type=submit value="提交">
    </form>
      

  3.   

    直接获取text值是做不到的。推荐2个方法。1,做一个分类的表(表1),里面放text与value值,这样可以对应起来。
    表2中只放value值,需要echo出来的时候,把表1与表2结合起来就好了。2,在提交前,用switch的功能,将value值替换成text