php模板取值

WBOY
WBOYOriginal
2016-06-23 13:10:541096browse


                    
                    " />
                    " />
                    " />
                    " />
                    " />
                    " />
                    
                    <script> <br /> function emptyrules(){ <br /> var city1 = $("#city").html(); <br /> var person_type1 = $("#person_type").html(); <br /> var province1 = $("#province").html(); <br /> var name1 = $("#name").html(); <br /> var idcard1 = $("#idcard").html(); <br /> var person_id1 = $("#person_id").html(); <br /> if(city1 == " " || person_type1 == " " || province1 == " " || name1 == " " || idcard1 ==" " || person_id1 == " "){ <br /> alert('请将信息填写完整!'); <br /> return false; <br /> }else{ <br /> alert('输入正确!'); <br /> return true; <br /> } <br /> } <br /> </script>

怎样取这代码里面的变量,然后判断他们是否为空?
var city1 = $("#city").html(); 这样取对不对,感觉取不出来啊!!求指教!


回复讨论(解决方案)

var city1 = $("#city"). val();

另外,没见到加载 jQuery 的代码

你那个取值方法错了 版主已经给你改了 function emptyrules() 这个函数什么时候调用你没有贴出来 有return 的话别忘记在onlick 方法前面加一个return 

if(city1 == " " || person_type1 == " " || province1 == " " || name1 == " " || idcard1 ==" " || person_id1 == " "){
                     alert('请将信息填写完整!');
                     return false;
                     }else{
                     alert(name1);
                     alert('输入正确!');
                     return true;
                     }
                     }


这里面的alert(name1)  在输出时为什么输出的是undefined ?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn