【问题标题】:Get value select (Javascript) and Grid in Electronjs在 Electronjs 中获取值选择(Javascript)和网格
【发布时间】:2020-10-20 15:17:15
【问题描述】:

我不知道为什么我的 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()
        })
    }
};

picture of my problem

我还有一个问题,如何在 electronjs 中使用 grid ?因为 col-md/sm/XS ... 不起作用。

【问题讨论】:

  • 您能否提供 sel 的值?
  • 我的div的值
  • 您能否提供一些示例值或您传递给它的任何内容?

标签: javascript html css electron


【解决方案1】:

你试试用:

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

【讨论】:

  • 你确定对象 RES 有价值吗?
猜你喜欢
  • 2011-08-18
  • 1970-01-01
  • 2020-12-08
  • 2015-09-21
  • 1970-01-01
  • 1970-01-01
  • 2014-01-04
  • 2018-09-19
  • 2022-01-08
相关资源
最近更新 更多