开发者

why cant I do this in js

开发者 https://www.devze.com 2023-01-08 06:29 出处:网络
I want to do this <?php $dropDown = \"<select><option value=\\\"0\\\">1-50</option><option value=\\\"50\\\">51-100</option>开发者_如何学C<option value=\\\"100\\\"&

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

精彩评论

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