0

我收到 ReferenceError:something_anything_nothing 未定义错误...请帮助。

    <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>";
      ?>
4

2 回答 2

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

试试这个

于 2013-10-27T12:58:57.857 回答
0

您可能需要将 $l 中的值用引号括起来,如下所示:

$l='"something_nothing_anything"';
于 2013-10-27T12:59:03.773 回答