Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - svallin

Pages: [1]
1
I'm new in JS, i created a simple local grid with <input> and <select> elements inside the grid.  I'm aware that i can use other alternatives, but i prefer using the input and select.
I would like to access them using getElementByID in another JS function

My code is:

// Define a simple grid using <input> and <select> in the data
$(function () {
    var colM = [
    { title: "Num",       width:   70, dataType: "html", dataIndx: "num"     },
    { title: "Supplier",  width: 280,  dataType: "html", dataIndx: "supplier"}];

     var data = [
        { num:        '<input type="text" id="num" name="num" value=""/>',
          supplier:   '<select id="supplier" name="supplier" onchange="onchange_supplier(this.value,this.id);"><option value="" selected="selected"></option><option value="B">B1</option><option value="S">S2</option></select>',
          } ];
     
     var dataModel = {
            location: "local",                     
            data: data};
       
        var gObj = {
            dataModel: dataModel,
            colModel: colM, 
            bottomVisible: false,
            flexHeight:true,
            flexWidth: true,
            numberCell:false,
            title: "Add a new Order"};
        var $grid = $("div#grid").pqGrid(gObj);
});

// THE PROBLEM is that i cannot access the elements num and supplier because they are inside the grid.
function onclick_button() {
  document.getElementById("num").value='1';
  if (document.getElementById("supplier").value=="B") {
    // ...
  }
}

Do you know how do I need to do to refer to input and select elements?
Thank you.

Pages: [1]