Jump to content

Recommended Posts

ok, so i've been bugging everyone on these forums for awhile, and i appreciate everyones help.  i'm so close to finishing this, but i'm stuck once again.

 

<html>
<head>
    <title>helloscan</title>
          <!--refreshes page in seconds-->
          <meta http-equiv="refresh" content="50">
          <!--produces barcode number and make var-->        
          <meta http-equiv="scanner" content="javascript:doScan('%s');"/>
          <!--following enables scanner-->
          <meta http-equiv="scanner" content="start"/>
          <META HTTP-Equiv="scanner" Content="enabled" />
          <!--adds enter to end of barcode allowing keyevent to occur-->
          <META HTTP-Equiv="scanner" Content="autoenter:enabled" />
          <META HTTP-Equiv="keycapture" content="acceleratekey:all" />
          <META HTTP-Equiv="keycapture" content="keyvalue:0x0D; keyevent:'javascript:get_plunum()'" /> 
          <!--puts quitbutton near top right, for development-->       
          <meta http-equiv="quitbutton" content="visibility: visible;"/>       
    <script language="javascript" type="text/javascript">
    //produces variable for ae_xrefnum
      function doScan(data){
          var divEl = ("%s");
      }
      //on refresh, allows scanner to come back up
      function enablescanner(enable) {
         Object.InvokeMETAFunction('scanner', 'start');
         Object.InvokeMETAFunction('scanner', 'enabled');
         Object.InvokeMETAFunction('scanner', 'autoenter:enabled');
         }  
      </script>
      <script language="javascript" type="text/javascript">
      //will be called from meta tag after autoenter attached to scan,for now runs after button pressed checks to make sure ajax active, then send out query for ae_xrefnum
          function get_plunum() {
              var xmlHttp = false;
              xmlHttp = createXMLHttpRequest();
              xmlHttp.onreadystatechange = function () { handleStateChange(xmlHttp); }
              //sends to php to query
              var ae_xrefnum = document.getElementById('ae_xrefnum').value;
              var querystring = "?ae_xrefnum=" + ae_xrefnum;
              xmlHttp.open("GET", "helloscan2.php" + querystring, true);
              xmlHttp.send(null); 
              }
          function createXMLHttpRequest() {
              var xmlHttp = false;
              try {// code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlHttp = new XMLHttpRequest();
              }
              catch (err) {// code for IE6, IE5
                  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
              }
              return xmlHttp
              }
          function handleStateChange(xmlHttp){
          //receives data from server, and puts repsonse in ae_plunum field
              if (xmlHttp.readystate == 4 && xmlHttp.status == "complete") {
              document.myform.ae_plunum.value = xmlHttp.responseText;
              }
              }              
     </script>
</head>
<body onload="enablescanner(true)">
    <h3 align="center"><center><img src="ac moore" /></center>Please scan a barcode...</h3>
    <form  name="myform">
    ItemBarcode:
    <input type="text" id="ae_xrefnum" itembarcode="divE1" /> 
    <!--unhidden for development, once this populates with value from php, will then trigger another function for query-->
    plunum:
    <input type="text" id="ae_plunum" value="" oninput="get_price()" />
    <!--button here for development, will be removed once i see plunum can be populated-->
    <input type="button"  value="submit me" onclick="get_plunum()" />
    </form>
    <script language=javascript>
    //focuses on ae_xrefnum when refresh occurs or page loads
        {
          document.myform.ae_xrefnum.focus();
        }
    </script>
</body>
</html>

 

I'm finally getting the response i need from my php file, but

 

document.myform.ae_plunum.value = xmlHttp.responseText; 

 

doesn't fill in the ae_plunum field. any insight would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/237584-using-responsetext-to-fill-in-field/
Share on other sites

MrDav for such a short amount of code you have a lot of errors. You are using deleted tags which will only give you problems in the long run and will break your program in various browsers. I suggest you go to http://validator.w3.org/ and fix your problems

 

For the 'will not write' problem change this function:

 

function handleStateChange(xmlHttp){
  //receives data from server, and puts repsonse in ae_plunum field
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
	document.getElementById('ae_plunum').value = xmlHttp.responseText;
}
}

yea i though that would work to, but it doesn't.  I did fix some of the errors in my code, but this is ment for an MK500, an item scanner,  using it's pocket brower application.  Any one else have any idea why this isn't working?  Everything i've looked through said this should populate this field but it won't

thanks fugix, but i can grab the value from ae_xrefnum, and it goes to my php script to query, and returns the correct result according to firebug, but what i need is for that result to populate my other field, ae_plunum.  I was messing around with the javascript debugger, and it breaks at

xmlHttp.onreadystatechange = function () {
                  handleStateChange(xmlHttp);
              };

but it doesn't call on that function for some reason.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.