Question

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>";
      ?>
Was it helpful?

Solution

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

$l='"something_nothing_anything"';

OTHER TIPS

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

Try this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top