开发者

Passing string variables to a javascript function via ahref

开发者 https://www.devze.com 2023-03-26 04:43 出处:网络
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.

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

精彩评论

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