我创建了一个Javascript函数,该函数根据传入的参数返回按钮的html代码。我在表td中调用该函数,该表使用php foreach循环动态加载。当我加载页面时,第一行中的特定td中没有返回任何按钮。我什至尝试返回仅字符串,它仍然是空的。我什至尝试返回仅字符串,它仍然是空的。第一行有什么方法可以调用该函数?
function formatCancelReturn(par_number,group_id,trans_id){
var base_url = "<?php echo base_url(); ?>";
var par=par_number;
var filename=group_id;//.replace(/-/g , "")
var file_path = base_url+'assets/uploads/rre/'+filename+".pdf";
var file_exists = getFile(filename);
if (file_exists.includes('TRUE')){
document.write(`<button class="btn btn-default" id="idReturn"
onclick="Return('${trans_id}')"><i class="fa fa-close"></i>
Cancel</button>`);
}else{
document.write(`<button class="btn btn-default" id="idCancelReturn"
onclick="CancelReturn('${trans_id}')"><i class="fa fa-close"></i>
Cancel</button>`);
}
}
```Here's where I call the JavaScript function
<?php $x = 0;
foreach ($returndata as $key => $value) {
$baseUrl = base_url(); ?>
<tr>
<td><input type='checkbox' disabled></td>
<td align="center"><a href="<?php echo $baseUrl ?>PPE/get_ppe_info/<?php echo $value['equipment_info_id'] ?>"><?php echo $value['equipment_info_asset_tag'] ?></a></td>
<td align="center"><div><strong><a href="<?php echo $baseUrl ?>Employee/Employee_page/<?php echo $value['issued_to_emp_id'] ?>"><?php echo $value['temp_issued_to'] ?></a></strong><br><?php echo $value['designation_to'] ?><br><?php echo $value['issued_to_office']?></div></td>
<td align="center"><div><strong><a href="<?php echo $baseUrl ?>Employee/Employee_page/<?php echo $value['issued_from_emp_id'] ?>"><?php echo $value['temp_issued_by'] ?></a></strong><br><?php echo $value['designation_by'] ?><br><?php echo $value['issued_by_office']?></div></td>
<td align="center"><?php echo $value['par_number'] ?></td>
<td align="center"><?php echo $value['ownership_status'] ?></td>
<td align="center"></td>
<td align="center" id="cancel">
<script type="text/javascript">
formatCancelReturn("<?php echo $value['par_number'] ?>", "<?php echo $value['group_id'] ?>", "<?php echo $value['trans_id'] ?>");
</script></td>
<td align="center" style="visibility: hidden;"><?php echo $value['document_type'] ?></td>
</tr>
<?php $x = $x + 1;
} ?>