首页 > 解决方案 > 在 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 ... 不起作用。

标签: javascripthtmlcsselectron

解决方案


你尝试使用:

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()
        })
    }
};


推荐阅读