...every time? PLEASE HELP!!!! I CANT FIGURE IT OUT!!!!
I am trying to submit a number in a text field, pass the number through mySql queries on a separate php page and reset the textbox to empty. All without leaving the page with the user's textbox. When i submit numbers the textbox resets but data is only added to the database when the same number is entered twice in a row. I cant figure out why this is, I hope it's something obvious and really need some help!!!! Is there anything in the code below that might cause this??
--------------------------------------------------------------------
<script type="text/javascript">
function update(value1)
{
doAjax("behind_scan.php" , "id="+value1);
}
function doAjax(url , str )
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
url=url+"?"+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
//alert(xmlhttp.responseText)
document.forms.myform.scanner.value = "";
document.forms.myform.scanner.focus();
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>
---------------------------------------------------------
here is the tag for the textbox:
<input type="text" id="scanner" name="scanner" onchange="update(this.value)" />
I am trying to submit a number in a text field, pass the number through mySql queries on a separate php page and reset the textbox to empty. All without leaving the page with the user's textbox. When i submit numbers the textbox resets but data is only added to the database when the same number is entered twice in a row. I cant figure out why this is, I hope it's something obvious and really need some help!!!! Is there anything in the code below that might cause this??
--------------------------------------------------------------------
<script type="text/javascript">
function update(value1)
{
doAjax("behind_scan.php" , "id="+value1);
}
function doAjax(url , str )
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
url=url+"?"+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
//alert(xmlhttp.responseText)
document.forms.myform.scanner.value = "";
document.forms.myform.scanner.focus();
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>
---------------------------------------------------------
here is the tag for the textbox:
<input type="text" id="scanner" name="scanner" onchange="update(this.value)" />