我修复了
confirmReset(\''.$nodetitle.', '.$nodeid.'\')
问题:
我想在if用户按下按钮时运行一个简单的JavaScript函数,提醒确认显示页面的ID
和TITLE
并最终重定向自定义网址
我的问题只是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
未返回的数字
谢谢你帮助我的朋友......
答案 0 :(得分:0)
PHP
<?php
$nodetitle = "Title one";
$nodeid = 150;
?>
HTML
<button class="btn" onclick="return confirmReset('
<?php echo $nodetitle;?>', '
<?php echo $nodeid;?>');">
Hello World
</button>
的Javascript
<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>