0

In this Code i try to get the value from text-field and dropdown listbox , I get values dynamically from user and send that value to webserices, In Given code get the value pass that values to webservice through javascript, but script didn't reponse to that code.. any one help me to fix this problem.

Here Code:
     <body style=" "><script type="text/JavaScript" >
      var xmlhttpuserid;
        functionmyFunction()  {
            var checkid=new Array();
            var userid = document.getElementById("userid").value;
            for(var i=0;i<2;i++)
            {
             if(document.getElementById('domainid'+i).checked==true)
             {
               checkid[i]=document.getElementById('domainid'+i).value;
               alert(checkid); 
             }
            }
         // var domainid = document.getElementById("").value;
        //alert(userid);
        var url= "../webservice/Passwordstation/ws_userauthpwdstation.jsp?  userid="+userid+"&domain="+checkid;

    alert(url);
        xmlhttpduserid=GetXmlHttpObject();
        if (xmlhttpduserid==null)
        {
          alert ("Your browser does not support Ajax HTTP");
          return;
        }

        xmlhttpduserid.onreadystatechange=getuserid;
        xmlhttpduserid.open("GET",url,true);
        xmlhttpduserid.send(null);   
}

        function GetXmlHttpObject()
           {
            //alert("GetXmlHttpObject1");
            if (window.XMLHttpRequest)
             {
               return new XMLHttpRequest();

             }
             if (window.ActiveXObject)
             {
                return new ActiveXObject("Microsoft.XMLHTTP");
             }
             return null;

           }

           function getuserid()
            {
              if (xmlhttpduserid.readyState==4)
              {
                var text=xmlhttpduserid.responseText;
                 //alert(text);
                 text=text.replace(/^\s+|\s+$/g,"");
            // alert("Text 2"+text);
                   if(text.match("SUCCESS"))
                    {
                       alert("Authenticate successfully");
                       window.location="accountmain.jsp";
                    }
                    else
                    {
                      alert("Please check your User id");
                    }
                }
             }
4

1 回答 1

0

我希望这能帮到您 。

您可以在 java 脚本中获取它们并将它们作为查询参数传递到查询中,就像对用户 id 所做的那样。

// var domainid = document.getElementById("").value;
        //alert(userid);
var textboxval = document.getElamentById("mytextbox").value;
var dropDown = document.getElementById("ddlViewBy");
var dropDownValue= dropDown.options[dropDown.selectedIndex].value;

        var url= "../webservice/Passwordstation/ws_userauthpwdstation.jsp?  userid="+userid+"&domain="+checkid&textboxvalue="+textboxval&selectedFromDropDown="+dropDownValue;
于 2013-02-03T20:08:42.427 回答