javascript

getElementById for elements that are not yet in the DOM

As far as I know document.getElementById('myId') will only look for HTML elements that are already in the document. Let's say I've created a new element via JS, but that I haven't appended it yet to the document body, is there's a way I can access this element by its id like I would normally do with getElementById? var newElement = docu...

How can I work with a multi-dimensional array in JavaScript?

I have a multi-dimensional array, no problem. How do I interrogator one of the arrays in order to ascertain if it actually holds any data? I am working with VS 2008 and what I can see in the debugger is, lets call the element x, is x{...}. However, if I try and use x.length i get the message 'undefined' - so how do I ascertain if the ...

javascript onclick remove single checkbox

Now I'm sure this is super easy, I have a function called "remove_deposit" which I want it to make the checkbox false if it's true. But I can't seem to get it to work.. function remove_deposit() { if(document.getElementById('deposit').checked == true) { document.getElementById('deposit').checked == false; }; }; Am I at le...

Python Unix time doesn't work in Javascript

In Python, using calendar.timegm(), I get a 10 digit result for a unix timestamp. When I put this into Javscript's setTime() function, it comes up with a date in 1970. It evidently needs a unix timestamp that is 13 digits long. How can this happen? Are they both counting from the same date? How can I use the same unix timestamp between...

Getting started with extJS

I don't get what I'm doing wrong. I'm trying to populate a form from a JSON string from the server and it doesn't work. I get nothing at all back. I examine the object and it's undefined. I've been beating my head against the wall for 3 days now. I need a simple example that works and I'll build from there. Here's the simple exampl...

Is it possible to handle up/down key in HTML input field?

I am building a autocomplete feature for input text field. Currently I could use mouse click to choose the selection, I'd like to add keyboard control to allow autocomplete control. I monitored the keycode in onkeyup event, it appears for up/down key, the key codes are both 0. I am wondering whether there is any better way to do so. T...

Javascript for/in loops through properties, not indexes and returns strings.

Ok, I have this code: var room = [ { time: 0, people: 0 } ]; and then: time = 5; for( var i in room ) { if( room[i].time < time ){ spliceIndex = i + 1; } } console.log(spliceIndex); And the console reads: 01 - Which means the 1 is concatenated which further means that i is a string, and not an integer as expected. Casting t...

How can I determine if an element is contained in an Array without looping?

How can I check whether a particular element is inside an array? I don't want to manually write a loop for this; instead I want to use a JavaScript built-in function, maybe something equivalent to new Array(0,1,2,3,6,9,12,15,18).Contains(5) //return false new Array(0,1,2,3,6,9,12,15,18).Contains(1) //return true Edit the question t...

Wicket & jQuery Overlap/Collision

I am currently working on a web app using Wicket and started using jQuery core (UI also) in it today. I ran into an issue I troubleshooted as a jQuery function (show(), slideDown()) colliding with some of the javascript Wicket auto-generated for an external form link. Before I get deeper into this project I am wondering if anyone has ha...

Javascript memory leaks after unloading a web page.

I have been reading up to try to make sense of memory leaks in browsers, esp. IE. I understand that the leaks are caused by a mismatch in garbage collection algorithms between the Javascript engine and the DOM object tree, and will persist past. What I don't understand is why (according to some statements in the articles I'm reading) the...

How to show/hide input value on focus?

I see this all over the web, but was wondering if anyone has the JavaScript code for the EASIEST way to show input value on blur, but hide in on focus. Thanks! ...

How to check if an object is an array

Possible Duplicate: How to detect if a variable is an array Hi, Just wondering if people could please let me know how to check for this using javascript. Thanks. Tony. ...

How to Change the URL without doing any Server Trip

I want to change the URL (QueryString Data) after the Page gets Displayed. How can i do it ? ...

How to iterate over a JSON structure ?

Hello, I have the following JSON structure: [ {"id":"10", "class": "child-of-9"}, {"id":"11", "classd": "child-of-10"}]; how to iterate over it using jquery or javascript? ...

AIR javascript class extension - air.URLLoader and static events

I am using multiple asynchronous air.URLLoader objects, and would like the events fired to be aware of the urlloader's "myId". The objects i am downloading have ids per se, so i'd like to know in my event listener callback function from which download id the progress/finished/error event came. code: # loader addonLoader = new air.URLLo...

Google Maps API, all markers opening the same infowindow.

I've got a page that retrieves a bunch of locations and some data about their associated markers and puts them on a Google Maps map. Each one is supposed to pop up its own little message when clicked on. However, clicking on ANY of them makes the most recently added message pop up at the most recently added marker. What gives? Am I not s...

Java ScriptEngine: using value on Java side ?

In a Java program I'm invoking a user-defined JavaScript program: File userJSFile=...; javax.script.ScriptEngineManager mgr=new ScriptEngineManager(); javax.script.ScriptEngine scripEngine= mgr.getEngineByExtension("js"); Object result=scripEngine.eval(new java.io.FileReader(userJSFile)); Now I would like to use 'result': how can I h...

Keeping history of hash/anchor changes in JavaScript

I'm currently implementing a JavaScript library that keeps track of the history of changes to the hash part in the address bar. The idea is that you can keep a state in the hash part, and then use the back button to go back to the previous state. In most of the recent browsers, this is automatic and you only have to poll the location.ha...

Multiple tabs same content

There are 6 divs on the page: A B C D E F G I want to reuse those divs to display content based on the tab. For example: Tab1 = A B Tab2 = A C Tab3 = A B C and so on... What would be the best way to do it( jQuery? ) Any examples? ...

Javascript And CSS files loading problem

We have more java script and css files in our WUI project. In some times, the files are not loading properly, due to the huge size. Did any body face this problem? or Do you have any idea to resolve this issue. ...