问题
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