Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. Ah, that's right. Damn functionally-scoped language... *grumblegrumble*
  2. Hmm...I'm not entirely sure why IE6 would be causing an error. And, of course, IE's error reporting tends to be less than helpful. I read something about IE having an issue with variable names. So, with that said, here are two shot-in-the-dark ideas you can try: 1. fix the last line to be this: newDiv.innerHTML = this.value; 2. rename your dbTbls variable as something else.
  3. Hmm...I'm not sure about your runtime error. I just did a quick test, and JavaScript CAN obtain a dynamically created element's id, so that probably isn't the issue. Have you looked at your code through Firefox, and/or Firebug? Their error messages tend to be helpful most of the time.
  4. Window.onload shouldn't be a problem with AJAX. It's often used as the first step for most JavaScript, err, scripts because it ensures that the entire document is loaded before any attempts to manipulate (i.e., obtaining references to elements, adding new elements, etc) are made. So, it shouldn't effect your AJAX. If speed's a concern, you could always use jQuery's ready function. It basically does the same thing as window.onload, but it checks for certain major things to load (like document.images) instead of waiting for the entire document to load. I'm not sure why you want to make two loops. Are you adding entirely new <select> dropdowns? Or just new <option> elements inside of one of them? Regarding your error, try replacing the last line with: newDiv.innerHTML = dbTbls.value; There may be an issue with JavaScript not being able to get a newly created element by getElementById (I'm not sure on this, so I'll do some tests myself). Thankfully, you still have the reference to the element you created in the newDiv variable, so you can access it directly from that, even though it's been attached to the document.
  5. Here's a quick question re: pass-by-reference... In PHP 5, object assignment is automatically done by reference, correct? So: $obj1 = new Object(); $obj2 = $obj1; $obj2->add(5); //obj1 added 5 also, because they both reference the same object, right? Does the same work for objects passed as arguments to another object's method? //front controller code $command = CommandResolver::getCommand($request); // <-- is $request a reference to the object, or a copy of it?
  6. In order to send query strings, you need to use the full path of the file (see example 3): http://www.php.net/manual/en/function.include.php
  7. I'm not 100% sure on what you're asking, but the <br> tags are being placed in the output by the nl2br() function. It quite literally means transform any newlines (nl) into (2) line break tags (br).
  8. Why not try something like: function Message(content) { this.content = content; } send(new Message("Hello World!"));
  9. This isn't too hard: <script type="text/javascript"> window.onload = function() { var menuName = document.forms["formName"].elements["label_mnu_1"]; //formName is whatever name you've given the form var url = document.forms["formName"].elements["url_link_mnu_1"]; menuName.onblur = function() { url.value += this.value + '/'; } } </script> Like I wrote above, "formName" should be replaced by the actual name of the form inside your HTML. This code modifies the second text input's value when the first input is no longer focused on (i.e., no longer has the cursor). If you want this to be done based on a submit button being clicked, let me know. It's almost as easy.
  10. For game design, you may want to look here: http://www.gamedev.net/
  11. I'm betting that your problem is that the DOM isn't fully loaded when the code to define your function is executed. A good, general practice is to put all of one's JavaScript code within a window.onload callback function. That way, you're ensured that the entire DOM is available to you. And, again, unobtrusive JavaScript is the way to go. Logically, it doesn't make sense for markup to know about the script(s) used on it, so why embed script code within the markup? There's no benefit to doing it that way, and several drawbacks. So, try something like: <script type="text/javascript"> window.onload = function() { var numRows = document.getElementById("numRows"); var dbTbls = document.getElementById("dbTbls"); dbTbls.onchange = function() { numRows.innerHTML = this.value; } } </script> Simple, compact, and should work. And, of course, there's the added benefit of having no script embedded in the markup, so you could move this code to an external file and it would still work.
  12. Ah, good point. But, to be honest, hardly anyone uses JavaScript for hyperlink hover effects any more anyway. If it's a bunch of links, just use CSS :hover to do it.
  13. I'm afraid I'm not quite sure what you're asking. ???
  14. First, is this site allowed by your college? Some professors don't like the idea of their lectures being freely available to the public. Make sure you're not violating any school rules before attempting this. Second, get a real image editing program. You should be able to get a discounted version of Photoshop through your school somehow. Jpeg and png are your friends. Third, what's proggR supposed to mean? Oh, wait...it's supposed to be an homage to Frogger? Why not go with progger instead? Fourth, I don't like the font all that much. "Sidestepping the Learning Curve" is somewhat hard to read. Finally, the rest looks solid, if plain. Not much else to say about it. It looks like a generic tabbed wiki.
  15. That's an ugly way to do it. Markup should have no knowledge of the script(s) used upon it. Try, instead: <html> <head> <title>Test</title> <script type="text/javascript"> window.onload = function() { var imgs = new Array("home_btn_h", "login_btn_h", "reg_btn_h", "del_forum_btn", "msgs_btn_h", "new_forum_btn_h", "reg_btn_h", "unread_btn_h"); for(var i = 0; i < imgs.length; i++) { imgs[i] = new Image(87, 30); imgs[i].src="assets/" + imgs[i] + ".gif"; alert("assets/" + imgs[i] + ".gif"); } } </script> </head> <body> <!-- markup --> </body> </html> Keep in mind, you may be overwriting your initial image values ("home_btn_h", etc) with the new Image objects. To be safe, you should have two arrays: one filled with the image names, one you build as you go on: var imgNames = new Array("home_btn_h", "login_btn_h", "reg_btn_h", "del_forum_btn", "msgs_btn_h", "new_forum_btn_h", "reg_btn_h", "unread_btn_h"); var imgs = new Array(); for(var i = 0; i < imgNames.length; i++) { imgs[i] = new Image(87, 30); imgs[i].src="assets/" + imgNames[i] + ".gif"; alert("assets/" + imgs[i] + ".gif"); }
  16. Better yet, don't rely on W3Schools for your code. They teach the bare minimum, and certainly not the best practices. Use unobtrusive JavaScript to localize errors and group code together: <script type="text/javascript"> window.onload = function() { var field1 = document.getElementById("field1"); var field2 = document.getElementById("field2"); var myButton = document.getElementsByTagName("button")[0]; //assumes that the button you want is the first in the page myButton.onclick = function() { field2.value = field1.value; } } </script>
  17. Without being able to see your PHP, try something like: value="<?php if(isset($_POST['FirstName'])){ echo $_POST['FirstName']; } ?>"
  18. You'll need a server-side script to process the login info and check to see if the user is logged on while they navigate from page to page. You've come to the right place, since PHP can do exactly what you're looking for.
  19. Now that I think about it, why not write all potential form inputs, then have them appear when the proper button/element is clicked? That's a lot easier than trying to add/remove elements from the document.
  20. Hmm...I don't think there's a way to control where new elements will attach themselves while using appendChild. It always puts the element at the end of the list of child elements. I think there may be a prependChild function, but that would force the new element to be the first child element, which is also something you don't want. You can try: form.innerHTML = "stuff"; Where stuff is everything you want within your <form> tag. This means, however, you'd have to rewrite your entire form, including the new input(s), as the "stuff" value.
  21. It's pretty basic: var newInput = document.createElement("input"); newInput.setAttribute("name", "userName"); newInput.setAttribute("type", "text"); form.appendChild(newInput); //assumes you have a variable named "form" that refers to an existing form. /* should create <input name="userName" type="text"> */
  22. You're having problems because document.write() overwrites the current document. If you want to create new elements, the safest way is to use the W3C functions, such as createElement(), createTextNode(), appendChild(), etc.
  23. Well, the easiest way to do it would be to give each link on the left an id. Then, in the click function, match that id with the href attribute of the special link. So, something like: $('a.next').click(function() { $("'" + $(this).attr('href') + "'").toggleClass("selected"); //you don't need to removeClass...toggle both adds and removes the class from the element. } //end jQuery script . . . <!-- Link in the lefthand menu --> <li class="main_courses"><a href="#tandoori" id="tandoori" class="selected">Tandoori dishes</a></li> <!-- Special link at the bottom of your content pane (remains the same) --> <a href="#tandoori" class="next">View Main Courses >></a> This should work, so long as you give each menu link on the left the same id as the href attribute of the special link. It works by simple text replacement. The href attribute is already "#something", so you should just be able to plug that into jQuery as an id reference.
  24. You have to remember/learn CSS selectors. You already have an id of tandoori for the link you want to change. Just replace the "'#gulaab_menu' ul li a" part with "'#tandoori'".
  25. It's probably not you but IE. The general rule of thumb is to develop for Firefox or Opera (using the Gecko engine), then 'modify' (read: hack) it to also work in IE. Regarding your JavaScript issues, feel free to create a new thread in the JavaScript section about them.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.