将字符串值作为参数传递给javascript [复制]

This question already has an answer here:

I`m trying to pass a string value to a JavaScript parameter. this is my html code

<input type="submit"  value="Edit" onclick="edit(<?php echo $key; ?> );" name="<?php echo $key; ?>" >

this is my JavaScript function

<script type="text/javascript">
function edit(id){
window.location.href="http://localhost/koko/edit-post.php?id="+id;
}
</script>

But this didn't work for me. How I solve this problem?

</div>
查看全部
drtppp75155
drtppp75155
2015/07/16 05:54
  • php
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复