- Upvotes Received
- 2
- Posts with Upvotes
- 2
- Upvoting Members
- 2
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Suddenly discovered that JavaScript is a great language! Thanks, Douglas Crockford.
- Interests
- Hiking, skiing, cycling, kayaking, piano playing, cooking
- PC Specs
- 1 Windows XP Pro 1 Linux KDE
67 Posted Topics
Re: Flash is not supported on most Apples. Otherwise it's the best option. Movies are one alternative. Another is JavaScript. With JS you can fade one image in while another fades out, giving an animated effect. You can animate styles. Animating left and/or top moves any DOM element. jQuery's 'animate()' method … | |
Re: Design issue. You can get code like this to work, but it's devilish hard and will probably find another bug for you tomorrow. You are trying to process content in a loop while also modifying the content. Do one job, then the other. 1) process all rows. (Get the total, … | |
Re: That would be cross-browser scripting (XSS - one page's JavaScript manipulating a site from another source) and it should not be allowed, for very good security reasons. Back up, rethink and redesign. And, sorry, I know you didn't want to hear this. | |
Re: Before you implement Airshow's excellent advice, back up to step 0. On your hard drive, create a folder. Let's say you're using Windows. Try C:\barcoscon. Place this code in that folder in a file named "index.html". (When you log onto any site on the web you are opening "index.html". Sign … | |
Re: Your 'load' element is first given a 'position: fixed;' and then 'position: absolute;'. 'fixed' is a position on screen, screen coordinates. 'absolute' is a position within its enclosing element. If the enclosing element is 'document.body' this could be scrolled off the screen. When one style overrides an earlier style, like … | |
Re: Probably badly written JavaScript running into naming conflicts. With one effect at a time, do a global change (MUST match case, whole words only) of one var name at a time from something simple, like 'a' to something unique, like 'my_876_a'. Do a quick check after each change. Warning: Murphy's … | |
Re: It looks like you have it. What is the problem? | |
Re: If you write one long line that does everything it's impossible to debug, even with a good tool like Firebug. Break it up: [code] //bad: doc.getEById( 'id here' ).value += doc.getAnotherEById.value + ...; // try: var ta = document.getElementById( 'textarea' ); alert( ta ); var ta_value = ta.value; alert( ta_value); … | |
Re: Do not write JavaScript in a string assigned to an 'onclick' property. Write it in a function in a <script> area and assign the function, thusly: [code] ... <body> ... <div id='an_id'> <!-- doesn't have to be a div, any element is OK --> ... <script type='text/JavaScript'> var some_elem = … | |
Re: I cannot read your code. I doubt anyone else can. The best JavaScript conventions published are by Crockford. Try googling "crockford javascript conventions" and following his advice. The name "thechosenone" is a superb example of why you should always use camelCase (theChoseNone or is it theChosenOne?) or lower_and_upper (the_chose_none or … | |
Re: "multiple select" implies that the user can select multiple items. Which one are we selecting? | |
Re: "using C#"? That might be a question for another forum. | |
Re: Hey, friend, that's way too much code! Hire a consultant to go that way. For a little friendly, free support, narrow the issue down to maybe a dozen lines and a well-focused question. In general, use a div around each neighborhood and assign an 'onclick' handler to the div. Code … | |
Re: Have you tried setting the display to style='display:"none";' ? | |
Re: What do you mean by 'context path' - the tree of routines which calls the current one? | |
| |
Re: Let's have an example. [code] function double( x ) { return 2 * x; } // 'x' is a placeholder, waiting for a value y = double( 23 ); // y === 46 [/code] When you put the 'double()' function into service, its parameter, 'x', is given a value. That … | |
Re: You actually want "help for JavaScript", not Java. If you want someone to write the code for you, this forum might not be the best choice. Here is a good place to get help with code you are writing. This job would be a good first JavaScript program. I'd make … | |
Re: Ask Goog for some help with "CSS box model". Then ask yourself what you mean by "center". | |
Re: Tables are much easier to build with 'insertRow()" and "insertCell()". (Yeah, I know. You've done it the hard way and it finally worked! Bravo. But please edit it back to the easy way, now that you know.) As you create your rows/cells, also create a map, a 2d array where … | |
Re: What are your goals here? To make it easy for the user? To make it easy for the shipping department? What is the allowable range? For example, could a month of October or less still be valid today? How far in the future should be go? Are dropdowns the best … | |
Re: What accordion? Your code or a library? It's certainly possible to click "Go to B" from page A, without destroying page A. | |
Re: Never saw 'return:false' before. Did you mean 'return false' (no colon) or is that something I need to learn about? | |
Re: Not sure it's your problem, but here's a general thought. All CSS measurements MUST have a dimension when they are non-zero. CSS will (theoretically) choke on 'width: 100;'. Therefore, JS will (theoretically) choke on 'xxx.style.width = 600'. However, most browsers accept unlabeled widths for most tags, since most HTML accepts … | |
Re: Taywin, Your normally superb posts hit a speed bump. "If you want to keep the value ..." perhaps you should attach it as a property to the function, no? [code] function maybe_later() { if ( maybe_later.timeout ) { ... } maybe_later.timeout = setTimeout( ... ); [/code] | |
Re: jQuery's 'parseJSON()' has the advantage of not using 'eval()' for those browsers that support a 'parseJSON()' function. Of course, that excludes you know who, so this isn't yet a big advantage. It is safe to 'eval()' JSON if your code creates the string to 'eval()'. It's an invitation to hackers … | |
Re: And your question? Without knowing where you are stumped, do try to ignore all the advice about using image software, not browsers, to size your images. Most browsers today can effectively resize photos even by rather small amounts. I just created an animation where a detail of the Sistine chapel … | |
Re: Gosh. You should get my book! (Except that it's not published, yet. You'll probably be an ace before it is ready.) Absent that, look for a more modern tutorial. IE9 is NOT a good learning browser. Chrome is very good for learning, as are Firefox and Opera. If you're going … ![]() | |
Re: There are a thousand lightbox functions on the web. Google and try some. If you can't find one you like, get back to us here. This is pretty simple JavaScripting. | |
Re: You're right. Something strange is happening. Post again with a lot more specifics on what you are using. In JavaScript 'typeof' is a unary operator, like the hyphen used to negate a number or the exclamation point used as a logical "not" operator. Saying "typeof(foo)" is identical to "typeof foo" … | |
Re: You forgot to ask your question. Your code looks OK so far. While you think about the question, take the <script> out of the <head> and put it at the end of the <body>. (See Souders [i]High Performance Web Sites[/i].) | |
Re: Yahoo guru (now Google guru) Steve Souders, in [I]High Performance[/I] recommends always placing your script at the end of the body section. I'm sure he knows more than almost anyone about script performance. In addition to the performance, it also fixes this bug as pointed out in the above reply. … | |
Re: Your post is missing some code. If you've not found the bug yet, post the part of the code that does the replace. Sounds easy. | |
Re: <vent>Tell your instructor that at least one highly experienced coder thinks he should be fired. Asking students to code a bubble (or other) sort is absurd. Sort algorithms are non-trivial but fully explored. In any modern language you call a 'sort()' method and you will never have to code a … | |
Re: Airshow, For the benefit of the rest of us, would you mind explaining that $() syntax? Thanks! | |
Re: 1) Move your script from the <head> to the bottom of the <body>. Then you won't need '$(...).ready'. See Souders book [I]High Performance Web Sites[/I] if you need more reasons. 2) Don't use jQuery if you don't have to. Hiding/showing a div is simply a matter of switching it's 'display' … ![]() | |
Re: Why is it you aren't just incrementing the size? 'setTimeout()' for zero millis? | |
Re: Google again. See the "getUTCxxx" methods. You are almost in business! Next topic: that's very nice code. Clean, readable and not likely to ever be a source of bugs. Couple suggestions: 1) Don't concat "getElementById" with other operations. Better: foo = document.getElementById( ... ); foo.innerHTML = ...; 2) Use an … | |
Re: I have tried to get double click/long click in other browsers and never got it to work right across browsers. You just won't get the control you need until JS has decent threads. (About which Eich says, "Over my dead body!" so don't hold your breath.) These days I redesign … | |
Re: Using 'a:visited' you can set the style for visited links: [code] /* CSS */ a:visited { background-color: red; } [/code] Is that enough? | |
Re: Raviaaa, That's a massive amount of code. Do you want to hire a consultant to work through it, or can you narrow it down so we can discuss a specific issue? | |
Re: Here's a QD function (untested, typos included no extra charge): [code] function show_briefly( div2show, millis2show_it ) { div2show.style.display = 'block'; // make it visible function hide() { div2show.style.display = 'none'; } setTimeout( hide, millis2show_it ); } [/code] That assumes that your help message is in 'div2show' and that the div … | |
Re: You are the second person this week being whacked by this CSS blunder. If an element is transparent, everything attached to the element will be transparent. You want opaque text on a transparent background. The only way to do this is to have two elements. The first element will be … | |
Re: Don't know about the plugin, but "trip[date]" is an expression, not a name. | |
Re: What, in English (not code) are you doing? Also, use functions to call 'setTimeout( function_not_string, millis )' [code] function do_foo() { /* does something here */ } // wrong: setTimeout( 'do_foo()', 1000 ); //string is bad // right: setTimeout( do_foo, 1000 ); // function is good [/code] The function will … | |
Re: You have to post some code to get help with an issue like this. Before you do, please be more specific about the problem, and take a very good look to see that you don't have two variables with the same name. If you do, rename one of them and … | |
Re: I second Taywin's motion. At the bottom of "foo.js" I always place this line: alert( 'foo.js loaded' ); If the alert pops up, you have no avoided several of the ways to screw up a .js file: wrong directory, wrong name, syntax error in file, ... Then you comment out … | |
Re: The previous post was right. Using the same ID for two (or more) DOM elements is an error. Unfortunately, it's not the kind of error that reports: "Hey, dummy! You used that ID already! Think up another one!". No such luck. It's an error and it will cause something to … | |
Re: Key codes and char codes are different. Here's a nice little tester: [URL="http://asquare.net/javascript/tests/KeyCode.html"]asquare.net/javascript/tests/KeyCode.html[/URL] | |
Re: $ - name of several different functions, much abused by libraries. Best known: jQuery, where it is an equivalent to a CSS selector. Assuming that's the one, '$("#amount") selects the DOM element whose ID is "amount". $xxx.keydown - "call me if there is a keystroke while I have focus" keydown( … |
The End.