我解决了
confirmReset(\''.$nodetitle.', '.$nodeid.'\')
题 :
如果用户按下按钮,我想在一个简单的JavaScript函数上运行,警报确认显示页面的
ID
和TITLE
,并且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;
}
此代码只返回数字,例如
Nodeid
和nodetitle
不返回谢谢您帮助我的朋友们...
最佳答案
的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>