gpt4 book ai didi

php - Json 到 Html 使用 bootbox?

转载 作者:行者123 更新时间:2023-11-30 23:20:20 27 4
gpt4 key购买 nike

我得到以下 JSON 值:

[{
"employee_id" : 10,
"name" : "george"
}, {
"employee_id" : 20,
"name" : "luke"
}, {
"employee_id" : 30,
"name" : "rita"
}
]

我想在 Bootstrap 箱中以表格格式显示值,我尝试了下面的代码,但无法生成它。

bootbox.confirm(
'<div style="font-size:15px;" class="accordion-body collapse in lst"><i class="icon-circle-arrow-right"</i>&nbsp&nbsp<b>Select the Server Size</b><br/><br/>\n\
<div class="content"><table style="border-collapse: inherit;" class = "table table-striped" cellspacing="0"><thead><tr><th>Select</th><th class="collapse">Name</th></tr></thead><tbody>'
for each (var item in obj) {
'<tr><td><input type="radio" id="server_size" name="server_size" value='+item.id+'><td>'+item.name+'</td></tbody></table></div></div>'
}
,'ok' , 'save');

最佳答案

请尝试在外部构建内容,然后将其传递给函数。不要忘记连接字符串:

var x = '<div style="font-size:15px;" class="accordion-body collapse in lst">'
+ '<i class="icon-circle-arrow-right"></i>&nbsp&nbsp'
+ '<b>Select the Server Size</b><br/><br/>\n'
+ '<div class="content"><table style="border-collapse: inherit;" '
+ 'class = "table table-striped" cellspacing="0"><thead><tr>'
+ '<th>Select</th><th class="collapse">Name</th></tr></thead><tbody>';

for each (var item in obj) {
x += '<tr><td><input type="radio" id="server_size" name="server_size"'
+ ' value='+item.id+'><td>'+item.name+'</td></tbody></table></div></div>';
}

bootbox.confirm(x,'ok','save');

关于php - Json 到 Html 使用 bootbox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15805130/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com