Maison  >  Article  >  développement back-end  >  php向html中js传值有关问题

php向html中js传值有关问题

WBOY
WBOYoriginal
2016-06-13 10:33:59813parcourir

php向html中js传值问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
状态 ";}else{echo " 已审核";}} ?>
选择照片 *


下面是start.html
HTML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->


怎么将$sh=1这个值,传到start.html中的js上,并做判断。谢谢各位了。
 

------解决方案--------------------
src="start.html?sh=1 
html中用写个函数postChk 用 document.location.search.length 就能接收到 ?sh=1
剩下的就是js处理这个字符串了。

------解决方案--------------------
PHP code
//$sh=1;echo "<script type="text/javascript">var sh = 1; </script>";<br><font color="#e78608">------解决方案--------------------</font><br>刚才没看清,既然已经输出了一个隐藏表单域,那就可以把$sh = 1;这行代码删掉了,修改js函数就行了(你贴出来的postChk()函数的定义存在两处错误。<br>
JScript code
function postChk(){    if (document.getElementById('sh').value == 1){ //获取id值为sh的隐藏域的值进行比较    alert('形象照审核中,暂时不能更改!'); //后一个单引号是全角的    return;  }} //漏掉一个花括号<div class="clear">
                 
              
              
        
            </div>
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Article précédent:也许需要高手才能解决,关于抓取Article suivant:请问贴