Jump to content

jeffman

Members
  • Posts

    7,761
  • Joined

  • Last visited

Everything posted by jeffman

  1. Well, you don't need a form for what you're doing now. You just need the inputs. If your end goal is to send data to your server, then yes you still need a form -- unless you want to use AJAX, but let's not talk about that unless it's already your plan..
  2. Close. In the following, I've "commented-out" lines that need to be removed or changed. If a change is needed, the changed line follows. You also need to add a closing '}' at the end of the function. function processForm() {var rawNumber = 0;var sqRoot = 0;var processForm = 0; rawNumber = document.getElementById("number").value;sqRoot = Math.sqrt(Number(rawNumber));// return sqRoot; //var div = document.getElementByID("sqrtDiv");var div = document.getElementById("sqrtDiv"); // notice the lowercase 'd'// div.innerHTML = sqRoot.value;div.innerHTML = sqRoot;}
  3. Better show me the new code.
  4. I probably gave you too many suggestions at once, since a couple of them cancel each other out. Here is your code slightly rearranged, and with a capital letter corrected. Try it. function processForm( ) {var rawNumber = 0;var sqRoot = 0; rawNumber = document.getElementById("number").value;sqRoot = Math.sqrt(Number(rawNumber));var div = document.getElementById("sqrtDiv");div.innerHTML = sqRoot;}
  5. These are roughly in order of importance. 1. processForm has no return value, so any code that calls it receives no data that can be written. At the end of the function, add this: return sqRoot; 2. document.write looks like it calls processForm, but it doesn't. To call the function it needs the parens at the end. 3. But don't bother, because you would be calling processForm from the button click AND as your script loads. document.write is in the wrong location. 4. But don't use document.write inside a function that gets called after page load. It obliterates the current document and opens a new one that no longer has your original content in it. Most of us never use it at all. Alert would be better. Better still, put a <p> element or something in your document and set its innerHTML to the value of sqRoot. 5. don't make your button a type="submit"; make it type="button". Otherwise, you'll submit the form and the page will reload. 6. In fact, if you're not submitting anything to your server, you don't need a form at all. You only need the form elements. That's still valid HTML. 7. Just to be safe, it's not a bad idea to pass rawNumber (a string) to the Number() function to explicity convert it to a number. Pass the return value of Number(rawNumber) to Math.sqrt(). 8. Since processForm doesn't actually do anything with the form argument, the argument doesn't need to be there, and you don't have to pass this.form to processForm when you call it.
  6. This script seems mostly unnecessary: document.write("<p>");if (i==0) { document.write("<div id='showCD' onclick='displayCDInfo(" + i + ")'></div>"); }elsefor (var i=1;i<x.length;i++) { document.write("<div id='showCD(" + i + ")' onclick='displayCDInfo(" + i + ")'></div>"); }document.write("</p>"); For one thing, because of the way document.write() works, two paragraphs get created, not one. (One at the top, and another at the bottom.) And neither of them encloses the div. They just sit there, empty. Next, the variable i is assigned the value 0 when the document loads. So your else condition never exists. And even if it did, you'd end up with a bazillion empty divs that don't get used. Also, the displayCDInfo() function does not use any arguments. The value of i is tracked separately as a global, and displayCDInfo() accesses it internally. So there is no point in writing the value of i into the #showCD div. All of which means that you only need the first div, and you don't need to create it using document.write(). You should be able to replace your whole script with this: <div id="showCD" onclick="displayCDInfo()"></div> Or have I misunderstood something?
  7. jeffman

    [PHP] Problem

    Maybe you need to verify the values of $name and $email? Are you extracting them from $_POST, maybe? Could that be a problem?
  8. It looks like you tried some debugging in your gettime function. Try expanding that with this: title.innerHTML = time0 + ", " + time1; just to see what those values really are.
  9. Any image in your cache will load with almost zero latency. Since your thumbnails ARE the images, even if you clear your cache, loading the thumbnail page will load all those images into cache again. I see no way of getting a load time in your slideshow without manually clearing your cache and programmatically going around the load-thumbnails stage.
  10. Be 100% certain your CS department will certify you in this stuff. CS departments are not all alike. Some focus a lot on engineering and teach things like Assembly language and C++, which is all good to know, but not the shortest path to your goal. I don't know you obviously, but I am a college professor, and I meet a lot of new students who make wrong assumptions about what their school offers and what department offers it.
  11. jeffman

    [PHP] Problem

    Try temporarily dumping more data. echo var_dump($_SESSION) . '<br>';$id= $_SESSION['id'];echo var_dump($id) . '<br>';$id2 = mysql_query("SELECT * from friends WHERE id1 = '{$id}'");echo var_dump($id2) . '<br>';$eid = mysql_fetch_assoc($id2);echo var_dump($eid);
  12. jeffman

    [PHP] Problem

    You shouldn't need the '{ }' characters. They are generally used to disambiguate arrays. And add a semicolon to the end of line 2. Other than that, it looks OK. You should probably switch to the mysqli functions. The mysql functions are deprecated and will eventually disappear. You should also add some error handling. The example here shows ways to do that.
  13. This is a double post. I started a response thread here.
  14. You don't need a database to do this. That just adds an extra step. If you want to save the file in native Excel format, you'll need to license a special library. But you don't have to do that. Fortunately, Excel reads flat files and converts them into spreadsheet format. A flat file in this case contains a unique line for each "row". Each "field" in each row is separated from the previous field with a tab. So all you really need to do is read and write to a text file.
  15. jeffman

    [PHP] Problem

    $id = mysql_query("SELECT * FROM `users` WHERE `name` = '{$name}' AND `email` = '{$email}'");$_SESSION['id'] = . $id["id"]; For starters, this won't work. As justsomeguy explained, $id is not an array. It's a resource. You pass it to mysql_fetch_assoc(), and the return value is an array. Same problem below: $id2 = mysql_query("SELECT * from Friends WHERE id1 = '{$id}'");$eid = mysql_fetch_assoc("{$id2['id2']}"); Pass $id2 to mysql_fetch_assoc(). $eid will then be an array. I don't know the structure of your table, but it looks like the value you want will be returned in $eid['id2']
  16. You are actually using two selectors separated by a comma. The first selector targets ALL <a> elements in a hover state; the second targets the #sparkle element, but not in a hover state. Combine them like this: #sparkle:hover
  17. A grouped selector is a list of any selectors separated by commas. The individual selectors can be element selectors, class selectors, contextual selectors, whatever. Unlike the other kinds of selectors, group selectors are a kind of shorthand. So yes, your example is a group selector. Hopefully, that answer helps you understand why it is not meaningful to ask the difference between a context selector and a group selector. It's like the difference between a package and a delivery truck.
  18. jeffman

    Newbie Help!

    Oops. I typed too quickly, and I've corrected the error. Try changing this if ((( to if (( Actually, you did somehow change the original. In moving this line, you dropped the second ')', which was the right thing to do to the line, but the ')' was there to close off the section containing all the '||' statements and probably should stay there. || ($_FILES["file"]["type"] == "image/png"))
  19. Works in my browser. As you debug this, are you refreshing the stylesheet as well as the HTML document?
  20. It works for me in FF, but the alert creates really annoying behavior. It might be the source of your problem. Also, my inclination is to attach the event handler to the window, not the body. Try experimenting with this. <!DOCTYPE html> <html> <head> <script> function showMsg() { document.getElementById("mytxt").innerHTML = window.innerHeight; } window.onresize = showMsg; </script> </head> <body> <p id="mytxt"></p> </body></html> Note that innerHeight is not available to IE before version 9. It sounds like you have code that handles that.
  21. jeffman

    Static Image

    background-attachment: fixed;
  22. It looks like that site uses jQuery, which is extremely common today, not just for slideshows, but to simplify tasks and add functionality to plain JavaScript.
  23. I can't comment on the wisdom of this, since I don't really understand your explanation, and it probably doesn't matter. The trick to doing what you want is to use variable variables. This simple loop does the basic extraction. To get the utility provided by all the constants that extract() can use, you'll have to add more code. foreach ($var_array as $key => $value) { $$key = $value;}
  24. jeffman

    Newbie Help!

    It throws that error because it's expecting a closing ')' before it gets to any other structures. -- You have too many '(' in your if structure.
  25. I don't see why they wouldn't be. The browser will load out.php exactly as if it had arrived there through a link or the user typing the address directly into the location bar.
×
×
  • Create New...