我有确认提醒,使用bootbox,js。在bootbox中,用户可以制作自定义的html表单。但是,我有一些从PHP foreach填充的表单元素/值。我试图这样写,但它不工作。警报没有被触发。如何在此javascript行中正确组合PHP结果?
bootbox.confirm({
title : "Testing",
message :
"<form id='test'>\
<h3>Dept: </h3>\
<table width='100%' cellspacing='0' cellpadding='3px'>\
<?php foreach($dept as $row_dept){ ?>
<tr>\
<td align='center' width='5%'><input type='checkbox' name='first_name' /></td>\
<td align='left'>"+<?php $row_dept->dept; ?>+"</td>\ /*If I remove this line, there is no error. But no value is shown*/
</tr>\
<?php }; ?>
<tr>\
<td colspan='2'><h3>Disposisi</h3>\<textarea id='disposisi' name='disposisi' class='form-control'></textarea></td>\
</tr>\
</table>\
</form>",
buttons : {
cancel : { label: '<i class="fa fa-times"></i> Batal' },
confirm : { label: '<i class="fa fa-check"></i> OK'}
},
callback: function (result) {
if(result == true){
var disposisi = $("#test").find('textarea[name=disposisi]').val();
alert(disposisi);
}
}
});
为什么你不呼应PHP价值? –
@RanaGhosh我试着用'<?php echo“test”这样简单的东西替换表单; ?>'。但是,它不工作。我认为问题在于'echo' – ashura91
是否显示控制台中的任何错误? –