Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. A couple of things are happening here. First, your stateChange function expects a parameter (called "i") that is never being passed to it when the readystate changes. Instead of setting up the readystatechange event handler like this: xmlHttp.onreadystatechange=stateChangexmlHttp.open("GET",url,true)xmlHttp.send(null)stateChange(i) Try this: xmlHttp.onreadystatechange=function() { stateChange(i); };xmlHttp.open("GET",url,true);xmlHttp.send(null); Second, because the requests are being sent asynchronously - xmlHttp.open("GET", url, true) - the while loop continues to execute. So, what happens is that you instantiate a new xmlHttp object, open it up, send the response, then - the next time through the loop - you instantiate a new xmlHttp object in the memory space that the first one was in, thereby overwritting any request that went out and ignoring the response.I would suggest either sending only one request - perhaps you could send an array of ids to the PHP script and have that script return either some text that you could parse on the client side - or, set up the requests so that they are not asnychronous - xmlHttp.open("GET", url, false). If you decide to go the synchronous route, the code would look something like this: while (i <= b){xmlHttp=GetXmlHttpObject()if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return }var url="damagecheck6.php"url=url+"?battle_id="+battleidurl=url+"&attacker_id="+iurl=url+"&varible=1"xmlHttp.open("GET",url,false)xmlHttp.send(null)stateChange(i)i++}
  2. It looks like your readystatechange event handler for the AJAX call in the getlist() function and the one for the AJAX call in the getheader() function are called the same - stateChanged. Further, it looks like you have declared stateChanged twice. This makes it so that when you call getlist() and when you call getheader(), both will execute the second stateChanged code: function stateChanged(){if (xmlHttp.readyState==4){document.getElementById("topmenu").innerHTML=xmlHttp.responseText;}} Try renaming your first stateChanged function to something like listStateChanged and the second one headerStateChanged. Then, in your getlist function change the code to look like this: xmlHttp.onreadystatechange=listStateChanged; And in your getheader function, change it to look like this: xmlHttp.onreadystatechange=headerStateChanged; I hope this helps.
  3. Something like this?: TestElement.setAttribute("name", "help");TestElement.setAttribute("id", "12"); Check out the XML DOM tutorial for more info: http://www.w3schools.com/dom/met_element_setattribute.aspEDIT: Sorry about the ";" in the code above, I always forget that you don't use those in VB.
  4. jesh

    Censured text

    There is a trick - it's a bit advanced and uses event handlers - you can use if you don't want to use anchors (<a></a>) and you don't want to explicitly type the onmouseover and onmouseout. It's a little overkill but it might help.If you put the spans like this: function SetUpCensuredElements(){ // get all the spans on the page. var spans = document.getElementsByTagName("span"); var span; // loop through all the spans. for(var i = 0; i < spans.length; i++) { span = spans[i]; if(span.className == "Censure") { // if the span has the appropriate class // set up the mouse events for this element span.onmouseover = CensureHover; span.onmouseout = CensureOut; } }}function CensureHover(e){ e = (e) ? e : window.event; var element = (e.target) ? e.target : e.srcElement; element.className = "CensureHover";}function CensureOut(e){ e = (e) ? e : window.event; var element = (e.target) ? e.target : e.srcElement; element.className = "Censure";}// This line tells the window to run your function when the page loads. This will// overwrite any other page load event handlers that you have set up, so // watch out when you use this. There are other ways to attach an event listener, but// I went for simplicity here...window.onload = SetUpCensuredElements; I'm sure you're all set with what you're doing, I just thought I'd show another way.
  5. I agree with everything everyone else said here, I'd just like to add that you might be able to use HTML Entities for some of the more basic equations: ∫<i>x</i><sup>2</sup> = 2<i>x</i> ∫ = ∫Entity References:http://www.w3schools.com/tags/ref_entities.asphttp://tlt.its.psu.edu/suggestions/interna...ehtml.html#mathPS. My Calculus is rusty, did I even get that equation correct?
  6. The only way I know of to do anything with files in the browser (client-side) is to use VBScript/ActiveX in Internet Explorer on Windows machines. It is not possible to access the file system using Javascript.The only thing I can think of would be to get the string value that is assigned to the file input element and check the last 4 characters to see if it is ".txt".HTML <input type="file" id="theFile" /> Javascript var filename = document.getElementById("theFile").value;if(filename.match(/\.txt$/i)){ // the filename ends with ".txt".} Other than this, you'll have to do all the validation on the server.
  7. Brutal. It's no wonder I don't write VB. Sorry you're stuck with it on your project!
  8. JSP (JavaServer Pages) is typically Java. What you're trying to do (create an Excel file using javascript) is not possible. What you can do, however, is have the user click a button which loads a jsp file which creates the Excel file on the server. Check out this link to get you started:http://www.google.com/search?hl=en&q=java+excel
  9. I also looked at that and there is a problem that occurs before that "menuitem1 has no properties" error: It looks like you are creating the menu objects like this:var menuitem1 = new menu(7,1,"hidden"); Which then runs this code: divname="subglobal"+thisitem;...this.thediv = document.getElementById(divname); Whichs tells the DOM that there is an element with an id of "subglobal1". However, there aren't any elements in your HTML with an id of "subglobal1", it starts with "subglobal2" and goes up to "subglobal8". Fix that and you might fix all the javascript bugs.
  10. Yeah, just like I remembered, this does not work in IE. You have to use:<script type="text/javascript" src="link.js"></script>
  11. jesh

    Regexp

    Brilliant. Thanks for posting the link to that article!
  12. jesh

    locale

    I'm going to say that the answer to that is no. If the information is being submitted to the server, perhaps you could get the time on the server-side when the request comes in rather than use the client-side time.
  13. Or, if you need to rely totally on client-side, you could use document.write to write out the code needed to display the clock:document.write("<div id=\"clock\">The Clock code goes here...</div>"); Or, using the XML DOM, you could create the elements and add them to your document: var div = document.createElement("div");div.id = "clock";div.appendChild(document.createTextNode("some text would go here"));document.body.insertBefore(div, document.body.firstChild);
  14. The HTML validates, but does the included script execute?
  15. Hmm. Something like this? Do While Right(theString, 1) = (Chr(13) & Chr(10)) theString = Replace(theString, (Chr(13) & Chr(10)), "", Len(theString), 1)Loop uggggh....VB
  16. When it was working before, was it on the same computer? Was it the same directory? If you recently changed the directory that the files are uploaded to, you might verify that the permissions on that directory are set such that PHP can write files to it.
  17. jesh

    Modal window

    According to this page - http://msdn.microsoft.com/workshop/author/...modaldialog.asp - that second parameter in the showModalDialog method is looking for "arguments to use when displaying the document" rather than the window name (as in the open method).You might simply try this instead: window.showModalDialog(theURL,"",features); Also notice that the window features are "semicolon-delimited" values rather than comma-delimited and that the feature names are different.Compare the features listed on that page (above) to the features expected by the window.open() function:http://www.w3schools.com/htmldom/met_win_open.asp
  18. Perhaps something like this: <html><body><div>Some Content</div><script>var h1 = document.createElement("h1");var a = document.createElement("a");a.href = "blablabla";a.appendChild(document.createTextNode("blablabla"));h1.appendChild(a);document.body.insertBefore(h1, document.body.firstChild);</script></body></html> Check out the XML DOM Tutorial for more info.
  19. Your first AJAX call: var url="./list.php";url=url+"?sid="+Math.random();xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null); is returning an entire page - <html></html> tags and all. When you are setting this as the innerHTML for the div, you end up having multiple <html></html> elements on the page. That's one of the problems you'll have to fix.Your second AJAX call: (http://www.licut.com/movie/header.php?movieid=1&user=michael&sid=0.8234120877594866) var url="./header.php";url=url+"?movieid="+ movieid;url=url+"&user="+ user;url=url+"&sid="+Math.random();xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null); also returns an entire page - <html></html> tags and all. Additionally, in this AJAX response, there is the following: That extra <script> tag is causing some additional problems.Typically, when you are using AJAX, rather than returning an entire page worth of content, you'll only want to return specific text (or XML). Rather than return the entire page, you want, for example, to return only the links and images that you want to be inside that div.
  20. I'm 97% sure that you're going to have to convert the XML Document object into a string and then send that string to your PHP script.
  21. Does it? I've never had any luck getting that to work. I've always had to use the end tag (</script>).
  22. If you are into photography, you could make a photo gallery. HTML and CSS for the front end and PHP and MySQL for the back end. You could even throw in AJAX to help switch from one image display to the other (e.g. Click on a thumbnail and use AJAX to load the image and the image description). The AJAX response could come back as XML (so you can return more than one piece of data) and you could use the XML DOM to parse the XML for the information you need.
  23. I can't speak much about the future of .NET (it seems to be going strong - I make my living writing code for it). Web Services, on the other hand, because they use XML to communicate between applications, can be written in any environment for any programming language. Because of this, Web Services will most likely be around for a long, long time.
  24. Wasn't Java supposed to be that end all answer to everyone's problems? Write one set of instructions and the operating system would run the virtual machine that would interpert the code. As long as an operating system had a virtual machine built for it, your Java program would run on it. But then the virtual machine couldn't be build without C/C++...So much for that!
×
×
  • Create New...