-3

UPDATED QUESTION

here is my code :

function BillerDetails() {

var iState = _xmlCFHttp.readyState;
var sStatus = "";

if (iState == 4) {

    if (_xmlCFHttp.responseXML.xml != "") {
        var $accNum = $("#CXACNUM");
        var $accNme = $("#CXACNAM");
        _xmlCFRecv.loadXML(_xmlCFHttp.responseXML.xml);
        sStatus = _xmlCFRecv.selectSingleNode("/result/status").text;

        if (sStatus == "1") {

            if ($("#CXCLRCD option[value='" + $(this).children("Data1").text() + "']").length == 0) {

                $("#CXACNUM").val($("#CXACNUM").val("Data5"));
                $("#CXACNAM").val($("#CXACNAM").val("Data4"));    
            }


        } else {
            var msg = _xmlCFRecv.selectSingleNode("/result/message").text;

            if (msg != "") {
                alert(msg);
            }
        }
    }
}
}

Data4 and Data5 is a field inside the database. these need to be display in the textbox. however as previous, it return output at the textbox as below :

Object Object
Izzy
  • 1
  • 3

3 Answers3

3

However when it display, it give me output :

[Object object]

This is because you are setting the returned value of val back to the same input, which is a jquery object

You need to simply do

$("#CXACNUM").val( JSON.stringify( Data5 ) );
gurvinder372
  • 66,980
  • 10
  • 72
  • 94
1

Try using JSON.stringify as

$("#CXACNUM").val(JSON.sringify(Data5));
Nitheesh
  • 19,238
  • 3
  • 22
  • 49
  • Hi I can delete the answer but by the time i was typing the answer there was no answer yet, check the timestamps its almost same, you dont ned to down vote for it, just ask to remove :( –  Dec 28 '17 at 10:33
  • hi, i tried using stringify. however, it still give me the same result. – Izzy Dec 28 '17 at 10:36
-1
      function BillerDetails() {

        var iState = _xmlCFHttp.readyState;
       var sStatus = "";

    if (iState == 4) {

          if (_xmlCFHttp.responseXML.xml != "") {
             var $accNum = $("#CXACNUM");
             var $accNme = $("#CXACNAM");
            _xmlCFRecv.loadXML(_xmlCFHttp.responseXML.xml);
            sStatus = _xmlCFRecv.selectSingleNode("/result/status").text;

         if (sStatus == "1") {

           if ($("#CXCLRCD option[value='" + $(this).children("Data1").text() + "']").length == 0) {
            var Data4Val=$(this).children("Data4").text();
            var Data5Val=$(this).children("Data5").text();
            $("#CXACNUM").val($("#CXACNUM").val(Data5Val));
            $("#CXACNAM").val($("#CXACNAM").val(Data4Val));    
        }


          } else {
                var msg = _xmlCFRecv.selectSingleNode("/result/message").text;

           if (msg != "") {
               alert(msg);
          }
       }
     }
  }
}

i have updated your code. hope this will work

Negi Rox
  • 3,828
  • 1
  • 11
  • 18