开发者

Passing string variables to a javascript function via ahref

So I have some php code that is generating links, and for the url I'm trying to pass the data to a javascript function.

echo "<a href=\"javascript:SubmitRemoval('", urlencode($item->roomname), "')\">Remove</a><br/>";

In the javascript function I am using this, but it does not seem to be removing the url encoding crap.

    <script type="text/javascript">
    function SubmitRemoval(roomname)
    {
        alert(decodeURI(roomname));
    }
</script>

I'm开发者_开发百科 not really a javascript pro, is there a better way to do this?


I don't think this can work. You are encoding with PHP and trying to decode with javascript.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜