3

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

Rishab
  • 1,484
  • 2
  • 11
  • 22
convicted
  • 35
  • 7

1 Answers1

0

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.'"'.');';
}
Jordan Lipana
  • 437
  • 2
  • 4
  • 18
Rishab
  • 1,484
  • 2
  • 11
  • 22