Home  >  Article  >  Backend Development  >  JS里面嵌入php代码,JS语法异常了,请大家帮小弟我看看

JS里面嵌入php代码,JS语法异常了,请大家帮小弟我看看

WBOY
WBOYOriginal
2016-06-13 10:33:47827browse

JS里面嵌入php代码,JS语法错误了,请大家帮我看看
for(var j=0; j; j++){
if(oSize.value == ''){
oSize.selected = true;
}
}

问题就出在这句话。oSize.value == '

错误代码是:Undefined index: j in
没有变量j,这个j并不是PHP变量,他是一个js变量,怎么让它嵌入在php里面。

请大家帮帮忙。

------解决方案--------------------
不可能的

你的 $Size 显然是一个数组

JScript code
var Size = ['<?php join("'", $Size) ?>'];for(var j=0; j<size.length j if size osize.selected="true;"></size.length><font color="#e78608">------解决方案--------------------</font><br>一个运行在前端  一个运行在后端  怎么能这样写在一起呢?<br>把$Size 转化成json对象赋值给js变量  然后交给js处理就好了<div class="clear">
                 
              
              
        
            </div>

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