Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. jesh

    PHP and AJAX

    I just want to repeat that unless the server tells the client that the client should be expecting some XML, the responseXML property will always be null. if ($num!=0) {$file= fopen("results.xml", "w") or exit("Unable to open file!");$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";$_xml .="<item>\r\n";while($row = mysql_fetch_array($result)){$_xml .= "\t<itemnumber>" . $row['itemnumber'] . "</itemnumber>\r\n";$_xml .= "\t<itemcat>" . $row['itemcat'] . "</itemcat>\r\n";;$_xml .= "\t<itemdesc>" . $row['itemdesc'] . "</itemdesc>\r\n";}$_xml .= "</item>";header("Content-Type: text/xml");echo $_xml;fwrite($file, $_xml);fclose($file);mysql_close($con);} else {
  2. jesh

    SQL <> MySQL

    Well, for starters, SQL is a type of language (Structured Query Language) that is used to query databases whereas MySQL is a database management system that allows you to create databases. You would use SQL to run queries against MySQL databases.
  3. jesh

    Online tests

    Rather than execute the checkIt() function on the click event of the submit button, try executing it on the submit event of the form. I think what is happening is that your code is trying to execute and the form is being submitted to "".Try this: <form name="q" action=" " onsubmit="checkIt(); return false;"><p>What is 5+5?</p><input type="radio" name="fi" />4<br /><input type="radio" name="fi" />10<br /><input type="radio" name="fi" />12<br /><input type="button" value="Check!"></form>
  4. Sorry, I skipped over that part of your original post. Heh.
  5. Didn't you (justsomeguy) have an example of something like this on one of these posts a week or two ago. Adapted from that, the javascript tester could look something like this:<script type="text/javascript">var test = new Image();test.src = "jsEnabled.php";</script> If jsEnabled.php is requested, then javascript is enabled.
  6. jesh

    PHP and AJAX

    Make sure that you set the Content-Type header in the server's response to "text/xml" or else that .responseXML property will be null.I think, in PHP, you do that like so:<?phpheader("Content-Type: text/xml");?>
  7. Typically, you would set your ID column to be auto-incrementing.If your table were set up like this: id username1 midnite2 aspnetguy3 Yahweh You'd INSERT a new record like this: INSERT INTO myTable (username) VALUES ('jesh'); And the table would look like this because of the auto-incrementing id column: id username1 midnite2 aspnetguy3 Yahweh4 jesh
  8. If you ever plan on moving the data over to a database rather than an XML file, it might be best to stick with the true = 1 and false = 0 because of the way databases store booleans. Also, "1" uses less memory than "yes" or "true". I'd choose this one:
  9. Well, I would think that you would need to figure out where you want the arrow to appear for each location and record the coordinates for that arrow in an array or a database table.For example, if the upper left corner of your map was (0,0) and the lower right corner of your map was something like (450, 295), then the bathroom icon would be somewhere around (428, 140). You'd have to have something in your code where you could ask "I want to know where the bathroom icon is" and the application would return you "(428, 140)". Then, using that point, you could place your arrow 428 pixels over from the left and 140 pixels down from the top.
  10. Here's one way: <select onchange="location.href = this.options[this.selectedIndex].value;"><option value="http://www.google.com/">Google</option><option value="http://www.w3schools.com/">W3Schools</option></select>
  11. I haven't used document.implementation.createDocument before, but if it is anything like the XmlHttpRequest (i.e. AJAX), you are prevented from accessing resources across different servers. This is to prevent cross-site scripting.If you need to access a resource that is on a different server from your own, you'll have to use the javascript to access a file on your own server which, in turn, could go out and fetch the file from the other server. PHP or ASP(.NET) or other server-side solutions would allow you to do this.
  12. You can get all of the inputs that are within a div by using this: var div = document.getElementById("myDiv");var inputs = div.getElementsByTagName("input"); But, for the above to work, you'd have to have your div declared like this (with an ID attribute rather than a NAME): <div id="myDiv">
  13. I've seen this little chart posted on a number of websites. It may help:http://www.howtocreate.co.uk/tutorials/jav...t/browserwindow
  14. Yeah, I think the problem is because you are trying to subtract 10 from "400px". Try using offsetLeft rather than style.left to get the position.var xpos = document.getElementById('object').offsetLeft;...document.getElementById('object').style.left = (xpos - 10) + "px";
  15. If you have a string, you can replace characters in that string with the replace method. If you wanted to replace all "$", "," and "." characters, you could do it like so:var string = "This is a string. It's worth, I don't know, $4.00.";var newstring = string.replace(/[$,\.]/g, "");
  16. Javascript is used mainly on the client whereas PHP is only on the server. It is true that some Internet users have javascript disabled, but I don't think it is safe to assume that it is a dying language. There are things that happen on websites that can only happen with javascript. AJAX, for example, is one of these things (AJAX, in case you weren't aware, stands for Asynchronous Javascript and XML).I think a good next step would be to begin learning the DOM. Most anything that you need to learn about javascript can be learned while going through the DOM tutorials. If you don't want to learn javascript or the DOM, you can work around that by using a strictly PHP method which could work something like this:1) User selects an item from a drop down menu and then clicks on a submit button (can't automatically submit without javascript/DOM) to submit the form to your PHP page.2) PHP processes the information included in the submit and builds a second drop down menu based on what the user selected.
  17. DOM is the way that javascript interacts with the various HTML Elements. For example, if you had a input in your form and you wanted to see what the value the user typed into that input, you'd use a combination of javascript and the DOM (but mostly just the DOM).HTML <input type="text" id="sometext" value="This is some default text." /> Javascript var text= document.getElementById("sometext").value;alert(text); So, in this example, document is the element that represents the entire HTML document. getElementById() is a method that allows us to get at a specific element within our document which has a specific id - in this case "sometext". getElementById returns a reference to the element that it finds - in this case, an input element. The input element, in turn, has some default properties. We use "value" here to get at whatever value happens to be in the input element.alert, in turn is a method of the window object. The window object represents the entire browser window. alert uses that window to pop up a message to the user. This is all part of the DOM.It really took me quite a long time before I finally realized that 80% or more of the coding I do in "javascript" is actually coding with the DOM (both HTML DOM and XML DOM). So, getting to know the DOM will help you with any scripting that you need to accomplish.
  18. Hey, no problem. If you plan on making this available to the general public via the Internet, I would suggest moving away from ActiveX and towards a server-side solution like PHP, ASP.NET, etc.In the server-side solution, the user browser would send the XML to the server, the server would then create the file, and then send that file back to the browser as a download. This way it would work for any browser, not just IE.
  19. Yes, since you require getting information from your database when something changes on your page, AJAX is probably the way you want to go.Building dynamic dropdown menus isn't terribly difficult, but it isn't terribly simple either. You might want to take a look at the HTML DOM tutorial - specifically these two sections:http://www.w3schools.com/htmldom/dom_obj_select.asphttp://www.w3schools.com/htmldom/dom_obj_option.asp
  20. jesh

    take website online

    You can name your initial page anything you want - it could be "thisismyhomepage_suckas.php" - but unless you configure your web server to display that file as the default file, your users will get the 404 error mentioned by aspnetguy.So, to avoid hassles of configuration on the web server, developers typically make their home pages called "index.php" (index.aspx, index.html, etc.) because the web servers come pre-configured to serve those files by default.
  21. Since you are using ActiveX, I have to assume that you only want this to work in IE. If that's the case, check out the Scripting.FileSystemObject. You can use it to open, read from, and write to files.Use this to create the FSO: var fso;fso = new ActiveXObject("Scripting.FileSystemObject"); Then check out this page for what to do with it:http://www.w3schools.com/asp/asp_ref_filesystem.asp
  22. It's a good idea to use relative sizes for the fonts so that users can increase/decrease the font size in order to make the text more readable.EDIT: I've always found this site to be very useful. They have a topic on accessibility.http://www.alistapart.com/topics/userscience/accessibility/
  23. Heh, it would appear that I have a bug in my bug tracking tool. Should have read "ECMAScript Version". Ironic.
  24. I have a little browser sniffer that I implemented into our bug tracking for our product and, according to it, the following is true:
  25. Sure. And since all I know of you is what I've read on this forum, I feel, in the context of this forum, it is safe to assume that you are always this way. If you truly took that quote to heart, you would recognize that your quoting of it was misplaced as you have shown yourself, in this conversation, to have absolutely no doubt that your way is the best way.By the way, thanks for bringing up Russell. It reminds me that I have a few essays of his on my bookshelves that I have neglected for far too long.
×
×
  • Create New...