我有確認提醒,使用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
是否顯示控制檯中的任何錯誤? –