javascript

Prepend 0 to a number in Javascript

I'm unsure how to prepend the number 0 to a number in javascript. Example input would be 1234, and this would wind up as 01234. Everything I try keeps adding the number zero, as opposed to prepending (obviously). Is there some way to escape the character, or some specific syntax for this? This is for chrome. ...

How could one create Google-Suggest style search suggestions with Javascript/AJAX?

How could one create Google-Suggest style search suggestions with Javascript/AJAX? References to articles would be much appreciated. I would like to retrieve the "suggestions" from a database. (Essentially just a list of keywords) Thank you. ...

Mootools Javascript can't push to array

I have an array set with the heights of each hidden div, but when I use it, the div instantly jumps down, rather than slowly sliding as when there is a literal number. EDIT: testing seems to reveal that it's a problem with the push method, as content_height.push(item.getElement('.moreInfo').offsetHeight);alert(content_height[i]);gives...

How long is a piece of $string… too long… javascript P2

How can I convert this PHP code to JavaScript? $string = "string How Long is a Piece of String?"; if (strlen($string) < 5) { echo "string is less than 5"; } else { echo "string is more than 5"; } ...

What's the best reading to start JavaScript?

Possible Duplicates: Best resources to learn JavaScript A Beginners' Guide to Learning JavaScript? Where to start to learn JavaScript (especially developing node.js+JQuery applications) from zero to expert level (having good C# and some PHP5 experience)? Can you recommend any must-read books and/or cool articles/blogs? ...

How do I run a script right after the head is loaded, but before the DOM?

Making a Google Chrome extension and need to run a script after the head is loaded, because there are scripts in the head and I need them to run. And before the DOM is loaded, because there's an inlined script in there that I need to beat. How would I do this? How do I detect when head loads? ...

Problems with Directions API in Google Maps V3 and jQuery

Hi, I'm trying to get Google Maps Directions API working with jQuery, and I have the following code.. http://pastebin.com/6jcGt706 Where #end is a select list in the HTML.. I'm Using jQuery 1.4.. I'm not sure as to what is going wrong.. Can you please help me with this... Would appreciate if any one could help me fix the problem with...

timer in JS without getting error in js

I would like to add a js window.setInterval timer to a page, but Firefox gives me a warning message: "A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue." window.setInterval(function() { doSomthing(); }, 500); Is there ...

changing jquery 'this' and 'next', to a specific element

Im working with the following code; <a href=\"#\" onClick=\"if($(this).next('div').css('display') == 'none') { $(this).next('div').show('fast'); } else { $(this).next('div').hide('fast'); } return false;\">Link</a> What i need to do, is change the part if($(this).next('div'), to target a specific element ID, not the next one from curr...

Response.write and target frame

Hi All, I am using two frames in my page. The page in Main fame will get the input and Top frame has to display the result page. I am using the following code in the mainframe page. But it shows error:"Microsoft JScript runtime error: 'topFrame' is undefined" Code: <frame src="" id="topFrame" target="topFrame" scrolling="no"> ...

alert in embedded webview

When embedding WebView in an application and loading html-pages in it, JavaScripts alert() do not work.Give me an example pls ...

Javascript protocol and events

What does the following code mean - <a href="javacsript:;" onClick="addItem(160)">some link</a> My basic doubt is which script is run when we click on the link ...

Passing parameter map (list of values) to JQuery

Hello, to initialize a javascript loaded grid, I need to pass a list of values from controller/gsp. Since the javascript is activated once the page is rendered/loaded, there may not be a direct way to do it. 2 possibilities 1. do an ajax call, and retrieve the list of values from the server 2. store the list in html as a hidden element...

How can I call mouseover event handler programmically in JavaScript

Hi, In my html, I have an html element with a mouseover event handler. Can you please tell me if it is possible for me to invoke that event handler programmically in JavaScript? Thank you. ...

Accordion nonfunctional in Opera

While working as expected in all other browsers, opera refuses to tween the height of content. oddly enough, as i sat annoyed rapidly clicking it over and over again, if it's closed, and you select some text, and keep clicking the same spot long enough, sometimes it pops open. lol. seriously. ahh, it seems to sometimes open the first t...

Problem loading js content with ajax

I have a page that loads content into a single div via a script in the page. It works fine but the problem is that I have a lightbox in one of the dynamically loaded pages that only works the first time you navigate to it (the script I got for the page loading is found here). Once you navigate to another area, then back again, the lightb...

Encoding non-English characters

Hey there! I'm having a bit of trouble here and I was hoping someone throws me a hint :) I'm getting some GET VARS with JS but I have trouble with non-latin charsets: cyrillic for example. The cyrillic var appears correct in the url but when I retrieve it with JS I get some dummy string. I was wondering of a function similar to "unesc...

Spry Collapsible Panel within Collapsible Panel, inconsistent errors.

Hello everyone it is me again with another question. The booking system located here http://www.divethegap.com/scuba-diving-programmes-dive-the-gap/divemaster-training.php?cat=16 There are 3 main collapsible panels controlled by the spry framework. There are then over a dozen more inside the first collapsible panel as you can see on tha...

Refactoring and assessment

I'm using javascript to toggle the display state of some objects based on the time of day. A sample of the code is given below. I was wondering if anyone could give a suggestion as to how I can refactor this code while at the same time improving the logic. switch(tcode) { case 'eur' : eur.setAttribute('style...

Passing time from server to client

Dear all, i am creating a digital clock using images & javascript but i want to pass a server time that time ... How to do that ... I am getting time from server and passing it to Date Following i have given snippet . var time_str = document.clock_form.time_str.value ; //alert (time_str); function dotime(){ theTime=setTime...