mindprints
Programmer
I have a javascript/php procedure that gets stringvalues from mysql based on user preferences.
When presenting the query results for the user I use a script that jumbles the results like airport flight info displays before stabilizing the text in a readable state.
My problem is: if a user gets impatient and clicks her selector button while the airport fx is still swirling about the text, I get an error because the airport fx script ends up with null strings.
I realize that the fix is to not let the user click the select button until the airport fx has done it's routine.
but I am not sure how to code that.
Here is my html that calls the js
Here is the funnyValue() function that sets up the query:
and here is the function that initiates the airport fx:
finally the error code from explorer:
and the airport fx javascript itself:
I am sure this is a simple problem - but I have played around with the ready states for some time now with out getting anywhere.
the site is viewable here:
Thank you
When presenting the query results for the user I use a script that jumbles the results like airport flight info displays before stabilizing the text in a readable state.
My problem is: if a user gets impatient and clicks her selector button while the airport fx is still swirling about the text, I get an error because the airport fx script ends up with null strings.
I realize that the fix is to not let the user click the select button until the airport fx has done it's routine.
but I am not sure how to code that.
Here is my html that calls the js
Code:
<form class="profiler">
<div class="tips">What sort of a name are you looking for?</div>
<input type="button" class="profilerf1" value="serious" onclick=
"funnyValue(1)" /><input type="button" class="profilerf2" value=
"funny" onclick="funnyValue(2)" /><input type="button" class=
"profilerf3" value="zanny" onclick="funnyValue(3)" />
Here is the funnyValue() function that sets up the query:
Code:
function funnyValue(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
// set the funny value //
var funnyVal = str
profilevalues[1] = funnyVal;
var url="/includes/getnames.php"
url=url+"?q="+profilevalues[1]+"&r="+profilevalues[2]+"&s="+profilevalues[3]
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
and here is the function that initiates the airport fx:
Code:
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
P = document.body.getElementsByTagName(tag);
T = P.length;
for (var i=0;i<T;i++) O[i] = new Olink(i);
for (var i=0;i<T;i++) setTimeout("O["+i+"].over();", i*8);
}
}
finally the error code from explorer:
Code:
Webpage Script Errors
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)
Timestamp: Tue, 21 Oct 2008 09:43:35 UTC
Message: 'obj.childNodes.0' is null or not an object
Line: 46
Char: 5
Code: 0
URI: [URL unfurl="true"]http://nameyoursalon.com/includes/js/airportfx.js[/URL]
Code:
var O = [];
var P,T;
/////////////////////////////////////////////////////////////////////////////////
var car = "-------------------- ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var tag = "p";
/////////////////////////////////////////////////////////////////////////////////
var L = car.length;
function Olink(o){
this.o = o;
this.txt = P[o].innerHTML;
P[o].innerHTML = "";
this.obj = P[o];
this.len = this.txt.length;
this.txa = "";
this.txo = "";
this.run = false;
this.stop = false;
this.cp = [];
Function("O["+o+"].over();return false;");
Function("O["+o+"].stop=true;setTimeout('P["+o+"].innerHTML=O["+o+"].txt;O["+o+"].stop=false;',1000);return false;");
this.display = function(){
with(this){
if(!stop){
run = false;
for(i=0;i<len;i++){
c = txa.charAt(i);
d = txt.charAt(i);
if(c != d){
cp[i]++;
run = true;
c = car.charAt(cp[i]);
if(cp[i] >= L) c=d;
txa = txa.substring(0,i)+c+txa.substring(i+1,999);
}
}
obj.childNodes[0].nodeValue = txa;
if(run) setTimeout("O["+o+"].display()", 32);
} else {
run = false;
txa = txt;
}
}
}
this.over = function(){
with(this){
txa="";
for(i=0;i<len;i++){
cp[i] = Math.round(Math.random()*20);
txa += car.charAt(cp[i]);
}
obj.innerHTML = txa;
if(!run) display();
}
}
}
function scramble(){
P = document.body.getElementsByTagName(tag);
T = P.length;
for (var i=0;i<T;i++) O[i] = new Olink(i);
for (var i=0;i<T;i++) setTimeout("O["+i+"].over();", i*16);
}
I am sure this is a simple problem - but I have played around with the ready states for some time now with out getting anywhere.
the site is viewable here:
Thank you