Inappbrowser ExecuteScript Return on Button Click


#1

I want to return some values from my Inappbrowser. So, i have a form with a Submit Button. I have added code on the click of the Submit Button which works inside the code( The alert statement works) but it is returning null to the callback function.

var code3 = "(function(){" + 
                  "var result = null;" +
                  "document.getElementById('submitButton').onclick = function(){" +
                  "alert(document.getElementById('userNameInput').value);" + //The alert statement works
                  "result = document.getElementById('userNameInput').value;" +
                  "return result;" +
                  "Login.submitLoginRequest();" +
                  "}" +
                  "})();";


  function loadStartCallBack(params) {
   console.log("loadStart Params", params);
     inAppBrowserRef.executeScript({ code: code3 }, function(results) {
       console.log("LoadstartResults", results); //Results is Null
     });
   // }
  }


 function loadStopCallBack(params){
   console.log("loadStopCallBack",params);
          inAppBrowserRef.executeScript({ code: code3 }, function(results) {
            console.log("LoadStopResults", results); //Results is Null
        } );           
   inAppBrowserRef.show();

 }

 function loadErrorCallBack(params){
    console.log("loadErrorCallBack",params);
 }