Guest ikkuhqhp Posted October 8, 2006 Share Posted October 8, 2006 Hi, I got this code, but it doesn't seem to work. Can you please help? Thanks in advance! <script language='javascript'>var nruser = 0 var users=new Array() var pagenr = 5users["0"]="user1" users["1"]="user2" users["2"]="user3"var xmlhttpfunction loadXMLDoc(){xmlhttp=null// code voor Mozilla, etc.if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest() }// code voor IEelse if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP") }if (xmlhttp!=null) { xmlhttp.onreadystatechange=state_Change xmlhttp.open("GET",'http://www.mysite.com/script.php?user='+users[nruser],true) xmlhttp.send(null) }else { alert("Your browser does not support XMLHTTP.") }}function state_Change(){// als xmlhttp is "loaded"if (xmlhttp.readyState==4) { // als "OK" if (xmlhttp.status==200) { alert('OK') handlereturn() } else { alert("Problem retrieving XML data") } }}function handlereturn() { var input = http.responseText; // this is wrong, it doesn't have access to that variable var actie = input.substr(0, 1); var tekst = input.substr(2, (input.length-2)); var output = ''; var geld = ''; if(actie == '*') { if(tekst == '1') output = 'output 1'; if(tekst == '2') output = 'output 2'; if(tekst == '3') output = 'output 3'; if(tekst == '4') output = 'output 4'; } else if(actie == '+') { output = 'return +'; } else if(actie == '-') { geld = tekst; output = 'return -'; }document.aanval_form.currentuser.value = users[nruser++];alert(output);}</script><form name="aanval_form"><input type="button" name="btnstart" value="Action!" onClick = "loadXMLDoc()"><input type="text" name="currentuser" id="currentuser" value='Slachtoffer' disabled="true"><br><br></form></body></HTML> I did a quick check, and it fails at the handlereturn, the error was bad syntax. The variable doesn't have acces to that part of the script.so, problem solved! Link to comment Share on other sites More sharing options...
jhecht Posted October 9, 2006 Share Posted October 9, 2006 <script language='javascript'>var nruser = 0var users=new Array()var pagenr = 5users["0"]="user1"users["1"]="user2"users["2"]="user3"var xmlhttpfunction loadXMLDoc(){xmlhttp=null// code voor Mozilla, etc.if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest()}// code voor IEelse if (window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}if (xmlhttp!=null){xmlhttp.onreadystatechange=state_Changexmlhttp.open("GET",'http://www.mysite.com/script.php?user='+users[nruser],true)xmlhttp.send(null)}else{alert("Your browser does not support XMLHTTP.")}}function state_Change(){// als xmlhttp is "loaded"if (xmlhttp.readyState==4){// als "OK"if (xmlhttp.status==200){alert('OK')handlereturn()}else{alert("Problem retrieving XML data")}}}function handlereturn(){var input = xmlhttp.responseText; // this is wrong, it doesn't have access to that variable//Use the right variable name, that should help alot.var actie = input.substr(0, 1);var tekst = input.substr(2, (input.length-2));var output = '';var geld = '';if(actie == '*'){if(tekst == '1') output = 'output 1';if(tekst == '2') output = 'output 2';if(tekst == '3') output = 'output 3';if(tekst == '4') output = 'output 4';}else if(actie == '+'){output = 'return +';}else if(actie == '-'){geld = tekst;output = 'return -';}document.aanval_form.currentuser.value = users[nruser++];alert(output);}</script><form name="aanval_form"><input type="button" name="btnstart" value="Action!" onClick = "loadXMLDoc()"><input type="text" name="currentuser" id="currentuser" value='Slachtoffer' disabled="true"><br><br></form></body></HTML> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now