简体   繁体   中英

How to insert textbox value & dxDatagrid all selected value in database on one single button click?

I am having input tag(textbox) and dxDatagrid. I am able to pass all selected value from dxDatagrid to database, but i also want to pass text box(which is outside of grid) value along with it on one button click.

$("#myButton").dxButton({
    text: "Test",
    onClick: function () {
        var stones = (JSON.stringify(dataGrid.getSelectedRowsData()));
        console.log(stones);
        updatedetgridReturnShip(stones);
    }
});



function updatedetgridReturnShip(stonedetailsarr){
    $('#sloader').show();
    $.ajax({
        url: 'php/insertGridReturnShipment.php',
        dataType: 'json',
        type: "POST",
        data: {
            returnstonedetails: stonedetailsarr,
            txtRefnoval : txtRefnoval
        },
        success: function (result) {
            alert(result);
            $('#sloader').hide();
            $("#myImportModal").modal("hide");
        }
    });
}

PHP Server side code:

$StoneArr = json_decode($returnstonedetails, true);

$updstmt = '';

foreach ($StoneArr as $Stone){
  $textboxval = $_POST['textboxval'];

  $refVal = json_decode($textboxval, true);

  $updstmt .= 'CALL return_ship_stones('.'"'.$Stone["carat"].'"'.',
  '.'"'.$Stone["clarity"].'"'.','.'"'.$Stone["color"].'"'.','.'"'.$Stone["invcno"].'"'.','.'"'.$Stone["invoicedate"].'"'.', '.'"'.$Stone["lab"].'"'.', 
  '.'"'.$Stone["measurement"].'"'.' , '.'"'.$Stone["ppt"].'"'.' , '.'"'.$Stone["qstonesid"].'"'.' , '.'"'.$Stone["qty"].'"'.' ,
  '.'"'.$Stone["reportno"].'"'.' , '.'"'.$Stone["shape"].'"'.' , '.'"'.$Stone["totalvalue"].'"'.', '.'"'.$refVal["referenceid"].'"'.');';
}

on one single click how to pass both textbox, and dxDatagrid value in database

You can use the jquery method to get the value from the text input by id and pass it to ajax data parameter:

$('#refno').val().trim()

Code Below:

function updatedetgridReturnShip(stonedetailsarr){
    $('#sloader').show();

      $.ajax({
          url: 'php/insertGridReturnShipment.php',
          dataType: 'json',
          type: "POST",
          data: {
              returnstonedetails: stonedetailsarr,
              txtRefnoval : txtRefnoval,
              textboxval: $('#refno').val().trim()
          },
          success: function (result) {
              alert(result);
              $('#sloader').hide();
              $("#myImportModal").modal("hide");
          }
      });
  }

PHP code:

<?
$returnstonedetails = $_REQUEST['returnstonedetails'];

$StoneArr = json_decode($returnstonedetails, true);

$updstmt = '';

foreach ($StoneArr as $Stone){
  $textboxval = $_REQUEST['textboxval'];
  $refVal = $textboxval;

  $updstmt .= 'CALL return_ship_stones('.'"'.$Stone["carat"].'"'.',
  '.'"'.$Stone["clarity"].'"'.','.'"'.$Stone["color"].'"'.','.'"'.$Stone["invcno"].'"'.','.'"'.$Stone["invoicedate"].'"'.', '.'"'.$Stone["lab"].'"'.', 
  '.'"'.$Stone["measurement"].'"'.' , '.'"'.$Stone["ppt"].'"'.' , '.'"'.$Stone["qstonesid"].'"'.' , '.'"'.$Stone["qty"].'"'.' ,
  '.'"'.$Stone["reportno"].'"'.' , '.'"'.$Stone["shape"].'"'.' , '.'"'.$Stone["totalvalue"].'"'.', '.'"'.$refVal.'"'.');';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM