ReferenceError:Something_anything_nothing is not defined

百般思念 提交于 2020-01-16 19:32:06

问题


I am getting ReferenceError:something_anything_nothing is not defined error... Please help.

    <script>
    function show(str)
    {
    var r=str;
    alert(r);
    }
    </script>


    <?php
    $l='something_nothing_anything';
    echo "<select onChange='show($l)'>";
     echo "<option></option>";
       echo "</select>";
      ?>

回答1:


You probably need to wrap the value in $l in quotes, like this:

$l='"something_nothing_anything"';



回答2:


$l='Somethin_nothin_anythin'; 
$buffer="<select onchange='show(\'".$l."\')'>"; 
$buffer.= "<option></option>"; 
$buffer.="</select>";
echo $buffer;

Try this



来源:https://stackoverflow.com/questions/19618228/referenceerrorsomething-anything-nothing-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!