开发者

why cant I do this in js

I want to do this

<?php
$dropDown = "<select><option value=\"0\">1-50</option><option value=\"50\">51-100</option>开发者_如何学C<option value=\"100\">151-200</option></select>";

?>    
<html>    
<head>
</head>
<body bgcolor="333333">
<script language="javascript">

<!--
var params = new Object();
params.dropDown = <?php print $dropDown; ?>;

</script> 
</script>
</body>
</html>

but it gives error. Whys that?


You're missing quotes? Basically, what you're writing here evaluates to

params.dropDown = <select><option value=\"0\">1-50</option><option value=\"50\">51-100</option><option value=\"100\">151-200</option></select>;

On a side note, <?= is more elegant than <?php print.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜