我解决了

confirmReset(\''.$nodetitle.', '.$nodeid.'\')


题 :

如果用户按下按钮,我想在一个简单的JavaScript函数上运行,警报确认显示页面的IDTITLE,并且Finaly重定向自定义网址
我的问题是ID已经通过,而Title没有通过!

变数

$nodetitle = "Title one";
$nodeid = 150;


的HTML

<button class="btn" onclick="return confirmReset('.$nodetitle.', '.$nodeid.');">


JAVASCRIPT

function confirmReset(nodetitle, nodeid) {
 var r = confirm('Node with ( ' + nodeid + nodetitle + ' ) Delete?');
 var url = window.location.pathname;
 var pathArray = url.split( '/' );
 var host = pathArray[1];

 if (r == true) {
    document.location.href = 'node/'  + nodeid + '/delete';
 } else {
   // alert('it didnt work');
 }
 return false;
}


此代码只返回数字,例如Nodeidnodetitle不返回

谢谢您帮助我的朋友们...

最佳答案

的PHP


<?php
$nodetitle = "Title one";
$nodeid = 150;
?>



  的HTML


<button class="btn" onclick="return confirmReset('
<?php echo $nodetitle;?>', '
<?php echo $nodeid;?>');">
    Hello World
</button>



  Java脚本


<script type="text/javascript">
    function confirmReset(nodetitle, nodeid) {
        var r = confirm('Node with ( ' + nodeid +', '+ nodetitle + ' ) Delete?');
        var url = window.location.pathname;
        var pathArray = url.split( '/' );
        var host = pathArray[1];
        if (r == true) {
            document.location.href = 'node/'  + nodeid + '/delete';
        }
        else {
            // alert('it didnt work');
        }
        return false;
    }
</script>

10-02 13:45