Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. Plus, if you are in the habit of using semi-colons after the braces, then you'll inadvertantly do something like this:do{};while()Which serves to separate the do command from the while command and there is no such thing, as far as I know, in javascript called do {}; (It's do-while).
  2. No problem, I just learned about match myself.It looks like the problem was that you had this in your first block of code:<script type = "test/javascript">rather than<script type = "text/javascript">
  3. It is because name will never explicitly equal true or false unless you explicitly set it to true or false. var name = false;if(name == false && name != true){ // this code will execute.} Just because if(name) and if(!name) pass the true/false check for an if statement, doesn't mean that name's value is true or false. var name = "Megan";if(name != true){ // this code will execute because name != true // it equals "Megan".}if(!name){ // this code will not execute because we've // set the value of name to "Megan".} I hope that helps.
  4. I agree with Skemcin comments regarding college degrees and careers. Just because you have a degree in something doesn't mean that this is what you will be doing in a career. I also think that the days of keeping the same job for 30 years, like our parents and grandparents, are long gone.I would, for the same reasons that Skemcin pointed out, choose the hardware route and then pick up software as you work. When I was working as an independent contractor for various clients, I had to bring in other people who where much more knowledged about hardware and server setup while I focused on software development. If you had a background in hardware and were also a programmer, you'd be much more desirable for employers.
  5. Hmm, try this instead:rightSelect.options[rightSelect.options.length] = option;//rightSelect.add(option, null);
  6. I'm not sure what you are trying to do with this: onclick=''std_window_resize( 100 ); It should be more like: onclick="std_window_resize( 100 );" But then, I don't see anywhere in your code where you have a function named "std_window_resize" declared so that will return an error until you build that function.
  7. Yes. You should not use semi-colons after blocks of code that are demarked with the curly braces.try{ // something}catch(e){ // something} not try{ // something};catch(e){ // somthing};
  8. I don't know the exact terminology for the ! operator (unary?) but it basically does what you said: var isSomething = false;if(!isSomething){ alert("This will alert!");} However, javascript treats pretty much any value as true other than null (and false). if(1004 && -1 && true && !null){ alert("Hi!");}if(){ alert("This won't alert.");} Because of this quirky behavior, you can use this to see if a variable has been set or not. var test;if(test){ alert("Not going to alert.");}test = 42;if(test){ alert("This will alert.");}
  9. var a = 2;var b = 5;return ++a * --b; This returns 12 because the following takes place on the return call:1) a in incremented from 2 to 3.2) b is decremented from 5 to 4.3) a (3) is multiplied by b (4) to get 12.4) return returns 12. var a = 2;var b = 5;return a++ * b--; This returns 10 because the following takes place:1) a (2) is multiplied by b (5) to get 10.2) a is incremented from 2 to 3.3) b is decremented from 5 to 4.4) return returns 10.In the first case, the varaible values are incremented/decremented before the operation while in the second case, they are incremented/decremented after the operation.
  10. 1. Look into using match(): var str = "this is a test is a test is a test is a test is a test";alert(str.match(/test/g)); 2. You might try using replace() to replace all instances of "e" with "e|" and then split on the "|" character.3. It doesn't look like there is any difference between those two methods. I tend to use substr() rather than slice() or substring(). I didn't even know slice() existed until I read this post. :)4. I don't use negative numbers much when I use these methods, but this example may help: var str = "Hello world!";alert(str.substring(5, -5)) // -> "Hello" It looks like it starts at position 5 and then returns the previous 5 characters (because of the negative number).5. I believe they are setting that to "null" because they are defining a new property using prototype. Simply writing this wouldn't do anything so they had to set it to some value - and they chose null: employee.prototype.salary; // wouldn't do much of anything However, since javascript is really lax about how it deals with properties and variables, you could just have easily done this: //employee.prototype.salary=nullfred.salary=20000 This would have given fred, a single instance of type employee, the property "salary" and assigned the value of 20000 to it. All other instances of employee would not have that property. So if you had an employee object named "mary", and you tried to use alert(mary.salary), you would get an undefined error. However, if you declare, using the prototype, that all instances of employee are to have a property called "salary", alert(mary.salary) would return null.6. See #5.7. match() returns an array. So, in your example: if (x.toLowerCase().match("silly")[0] == "silly") But, you could just as easily do: if(x.toLowerCase().match("silly"))
  11. One way to start would be to use CSS: <style type="text/css">iframe { display: none; }</style> This will make all of your iframes invisible when the page loads.
  12. Rather than assigning a string (e.g. "unClicky"), you need to assign a reference (e.g. unClicky). <html><body><button id="myButton">Click Me</button><script type="text/javascript">var myButton = document.getElementById("myButton");function handleClick(){ myButton.innerHTML = "You clicked it!"; myButton.onclick = handleUnClick;}function handleUnClick(){ myButton.innerHTML = "Click Me"; myButton.onclick = handleClick;}myButton.onclick = handleClick;</script></body></html>
  13. When assigning event handlers through the DOM, you're actually assigning a reference to a function rather than calling the function. So, rather than: aForm.aBn.onclick = "unClicky()"; You'll want: aForm.aBn.onclick = unClicky;
  14. What do you mean when you say you want a lot of colors in it? You have an array of colors, are you wanting to have each link use a different color? Or do you want a different color to appear each time the link is moused-over?
  15. In what order are you declaring the styles? Do you style the generic a elements before you style the a elements which are child elements of your div?For example: div a { color: #000000; }a { color: #ffffff; } Should be: a { color: #ffffff; }div a { color: #000000; } If this isn't the case, maybe you could post a link to your page?
  16. You might try "color" rather than "font-color".I tested this in Firefox and it works just fine: <html><head><style>body { background-color: #ff8c00; }a { color: #ffffff; }.black a { color: #000000; }</style></head><body><a href="http://www.w3schools.com/">link1</a><div class="black"><a href="http://www.w3schools.com/">link2</a></div></body></html> EDIT: heh, aspnetguy must have beat me by a second!
  17. You should simply be able to replace this in my code:#Nav { background-color: #b0c4de; height: 150px; } With this: #Nav { background-color: #b0c4de; height: 150px; position: fixed; width: 100%; } That works for me.
  18. As aspnetguy just (coincidentally) posted in another post, you may be able to use the media types in CSS to build a page specifically for printers. <link rel="stylesheet" type="text/css" href="main.css" media="all" /><link rel="stylesheet" type="text/css" href="print.css" media="print" /> Then, in your print.css file, you could hide (using display: none;) all of the content that you don't want to print.Incidentally, it's window.print() rather than print.window().
  19. Wait a second, when you say "client", do you mean the computer which is served the content from the webserver (as in client/server)? Or do you mean some business for whom you are developing the application (as in paying customer) and the printer is actually conntected to the server?If the printer is connected to the server, you may be able to find an API for interfacing with that printer.
  20. In your "get function" you have this: <?php But in your href you have this: <? Could that be the problem? Is your server set up to process "<?" as PHP code?
  21. This works for me in Firefox: <html><head> <title>Wired Chemist</title><style>body { margin: 0px; }#Nav { background-color: #b0c4de; height: 150px; }#Nav .Text { text-align: center; font-family: Arial, Helvetica, sans-serif; color: #4682B4; width: 600px; margin: auto;}#navH3 { margin: 0px; font-size: 30px;}#navP { font-size: 14px;}#navP:first-line { font-size: 20px;}</style></head><body><div id="Nav"> <div class="Text"> <h3 id="navH3">Wired Chemist</h3> <p id="navP">Chemistry | Mineralogy | Environmental | NMR<br><br> Instructional | Data Tables | Links </p> </div></div></body></html> Rather than having two separate divs - one for the background and another placed on top of it for the content - this uses one div for the nav bar with another div nested inside for the nav content.I hope it helps.
  22. jesh

    div height 100%

    Another suggestion is to set the height of the html and body elements explicitly to 100%: html, body { height: 100%; }#myDiv { height: 100%; } It tends to work for me. You may also have to set the margins to 0 for the body or add some margins/padding to the div to get it to work just right.
  23. I'm definitely not the XML guru you're looking for, but I ran some tests trying to help out someone else and they seemed to work for me. Check it out at this post:http://w3schools.invisionzone.com/index.php?showtopic=9461I hope it helps.
  24. Yep: <script type="text/javascript">function hover(obj){ if(obj.className == "off") { obj.className = "on"; } else { obj.className = "off"; }}</script><style type="text/css">.off { color : black; }.on { color: red; }</style><a class="off" href="http://www.w3schools.com/" onmouseover="hover(this);" onmouseout="hover(this);">W3Schools</a> Or, more simply: <style type="text/css">a { color: black; }a:hover { color: red; }</style><a href="http://www.w3schools.com/">W3Schools</a>
  25. jesh

    id tag

    Yes. If you have the following HTML:<input type="text" value="this is some text" id="tfield" /> You can get at each of the properties (and more) using the DOM: var input = document.getElementById("tfield");var type = input.type; // this will be "text"var value = input.value; // this will be "this is some text"var id = input.id; // this will be "tfield" Here's the part of the HTML DOM tutorial which speaks about inputs of type "password":http://www.w3schools.com/htmldom/dom_obj_password.asp
×
×
  • Create New...