javascript - 在 Electronjs 中获取值选择(Javascript)和网格
问题描述
我不知道为什么我的 div 中的值只出现一次...
function nbProduct(sel) {
var nbProduct = sel.options[sel.selectedIndex].text
$('#tableFacture').remove();
$('#tableFacture').remove();
for(var i =0;i < nbProduct;i++){
var nFacture = i + 1
$("#product").append("<table id='tableFacture'></table>")
$("#tableFacture").append("<th scope='row' id='rowProduct"+i+"'>Produit N°"+nFacture+"</th")
$("#rowProduct"+i+"").append("<div class='row' syle='margin-top: 40px;' id='"+i+"'><select onChange='typeProduct(this);'><option></option><option value='"+i+"'>Velo</option><option value='"+i+"'>Trottinette</option><option value='"+i+"'>Accessoires</option></select></div>")
}
function typeProduct(sel) {
var typeOfProduct = sel.options[sel.selectedIndex].text
var nbDiv = sel.options[sel.selectedIndex].value
if (typeOfProduct == 'Velo'){
$("#"+nbDiv+"").append("<div class='containerFacture><select id='factureVelo'><option></option></select></div>")
client.query('SELECT * FROM core_velo ORDER BY model DESC',(err,res)=>{
for(var i =0;i < res.rows.length;i++){
var item = res.rows[i];
var model = item['model']
$("#factureVelo").append("<option>"+model+"</option>")
}
client.end()
})
}
};
我还有一个问题,如何在 electronjs 中使用 grid ?因为 col-md/sm/XS ... 不起作用。
解决方案
你尝试使用:
function typeProduct(sel) {
var typeOfProduct = sel.options[sel.selectedIndex].text
var nbDiv = sel.options[sel.selectedIndex].value
if (typeOfProduct == 'Velo'){
$("#"+nbDiv+"").append("<div class='containerFacture col-xs-2 offset-xs-1'><select id='factureVelo'><option></option></select></div>")
client.query('SELECT * FROM core_velo ORDER BY model DESC',(err,res)=>{
var model ="";
$.each(res, function(index, value){
model += value.model;
})
$("#factureVelo").append("<option>"+model+"</option>")
}
client.end()
})
}
};
推荐阅读
- r - 在 R 中的箱形图旁边绘制垂直正态分布
- regex - 从 JMETER JSONPath 值中提取最后六位数字
- ruby-on-rails - 模型类的 Searchkick 聚合
- kubernetes - Kubernetes pod 因卷附加问题而失败
- python - 将 softmax 层添加到 LSTM 网络“冻结”输出
- javascript - 更改变量名称的 For 循环
- python - Flask 表单数据为空
- java - 如何解决 Android Studio 中的 Phenotype API 错误?
- r - 按组更改 siberDensityPlot 颜色
- python - 在 AWS Lambda 上运行 python 脚本时出错