문제

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>";
      ?>
도움이 되었습니까?

해결책

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

$l='"something_nothing_anything"';

다른 팁

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

Try this

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top