Heim  >  Artikel  >  Backend-Entwicklung  >  php向html中js传值有关问题

php向html中js传值有关问题

WBOY
WBOYOriginal
2016-06-13 10:33:59813Durchsuche

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>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:也许需要高手才能解决,关于抓取Nächster Artikel:请问贴