javascript

JavaScript: How to reverse order=[] arrays from last to first?

My js code does POST order.php?order[]=1&order[]=2&order[]=3&order[]=4&order[]=5&&action=update How to reverse it to order.php?order[]=5&order[]=4&order[]=3&order[]=2&order[]=1&&action=update ? JavaScript: order=[]; //var reversed = $(this).sortable("serialize").split("&").reverse().join("&"); //var order = reversed + '&action=update'; ...

Javascript: Pass array as optional method args

UPDATE: Here's my solution (inspired by accepted answer): function log(msg, values) { if(config.log == true){ msg = [msg]; var args = msg.concat(values); console.log.apply( this, args ); } } UPDATE2: Even better solution: function log(msg) { if(config.log == true){ msg = ...

Google Chrome and (cache or memory leaks).

Hello All, I have a big problem with Google Chrome and its memory. My app is displaying to user several image charts and reloads them every 10s. In the interval i have code like that var image = new Image(); var src = 'myurl/image'+new Date().getTime(); image.onload = function() { document.getElementById('myimage').src = src; ...

Four level connected dropdown boxes

I'm looking for four level connected drop down boxes. Unlike all the scripts I have seen on the internet I need all the options to be available if nothing is selected in the previous drop down. So I want something like combination of connected drop downs and ordinary drop down. If the selection is made, display appropriate options in oth...

jquery javascript error using $(...) selector

Hi, I'm migrating some old code to jquery: xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { $("#" + ajaxArea).html (xmlHttp.responseText); $("#" + ajaxArea).attr('title', 'Login'); $("#" + ajaxArea).dialog({ height : 140, modal : true }); } }; where ajaxArea is the ID of a DIV in the...

Wordpress Admin Panel Code Input

I've got a wordpress admin panel for one of my themes and one of the boxes has an input for some code to drive google adsense. when I put the code into the box and call it with my php tags the code comes out like this: <script type="\&quot;text/javascript\&quot;"><!-- google_ad_client = \"pub-9295546347478163\"; /* Leaderboard 5...

Form still posts back with return false in JS

it seems like #frmToDo still posts backs <form id="frmToDo" name="frmToDo"> ... <a id="btnSubmit" href="javascript:document.frmToDo.submit();">Add</a> google.load("jquery", 1); google.load("jqueryui", 1); google.setOnLoadCallback(function() { ... $("#frmToDo").submit(function() { return false; ... why will t...

What's the differenct between passing a function and the function call itself in javascript?

In the application I'm building I'm polling for a status update and I have noticed that if the call is made as follows the timeout fires continuously: setTimeout($.get("http://localhost:8080/status", function(data) { UpdateStatus(data);}), 1000); While if use a function instead the timeout fires every 1000 ms: setTimeout(function() ...

How to hide jQuery Sub-Menus(ddsmoothmenu)?

I'm new to jQuery and i must admit that i've understood nothing yet, the syntax appears to me as an unknown language although i thought that i had my experiences with javascript. Nevertheless i managed it to implement this menu in my asp.net masterpage's header. Even got it to work that the content-page is loaded with ajax with help fro...

How to remove sessionvariable when closing popup window?

I have a popup window where i store an a arraylist in sessionvariable, when clicking on closebutton (the X in the right top corner) or the cmd input button in the form i want to remove the sessionvariable containing my arraylist. How can i do this? The popup window is currently closed by a javascript: function cmdClose_onclick() { ...

Javascript array best practice to use [] instead of new array?

I read at many tutorials that the current best practices to create a new javascript array is to use "var arr = []" instead of "var arr = new Array()". What's the reasoning behind that? ...

Cancel a keystroke in jQuery

Is is possible (cross-browser compatible) to CANCEL a keystroke after a user has made it (for example on a textbox) The code I currently use edits the textbox value after the keystroke has been displayed: $('.number').keypress(function() { this.value = this.value.replace(/[^0-9\.]/g, ''); }); ...

Any good jQuery plugins to awesomify my pagination?

I have a basic pagination system that looks something like that: First | < Previous | 1, 2, [3], 4, 5 ... 100, 101, 102 | Next > | Last Nothing fancy really. I am looking at various plugins to improve the way the user would browse this, but so far I haven't found anything really new or interesting except: http://tympanus.net/jPagi...

why jquery detach element will cause a form to submit?

i wonder why in the following example, trying to detach an element (li) causes the form containing it to submit html <form id="frmToDo" name="frmToDo"> <p id="lineInput"> ... <input type="submit" id="btnSubmit" value="Add" /> </p> <ul id="todolist"> <!-- added in ajax --> </ul> </form> JS $("#frmToDo").submit(f...

Possible to rewrite url clientside with javascript without reloading page.

Is it possible to rewrite the URL in the URL-field on the client's browser? So when a person clicks on a link on my page something ajax happens (eg a tab shows up) i want the url to display the action without refreshing the page. Is this possible? ...

how to disable ckeditor 3 auto spellchecker ?

Hi there I've installed CKEditor 3.0 ,it work nice , but I want to disable the auto spellchecker I notice when I'm writing some words in the editor it manages to connect to "svc.spellchecker.net" to make spell check do you know any way to stop that feature ? thanks in advance ...

Wrapping javascript in <!-- -->

What's the point of wrapping javascript code in <!-- --> ? ...

How to use regex to strip [a-z]/[a-z]/ from a string?

Say a string is abc/xyz/IMPORTANT/DATA/@#!%@!%, and I just want IMPORTANT/DATA/!%#@%!#% I am terrible at regex, and really haven't learned JavaScript API yet ...

jQuery - field entry - how to duplicate and convert to seo friendly url

I have two HTML input fields article and url. How to duplicate field 'article' entry to field 'url' to SEO friendly link!? url allowed symbols a-z (capital letters converted to lowercase), url space symbol replace with dash -, url other symbols ignored. required typing just in field article <input type="text" name="article"> ur...

Cross browser window close event

Possible Duplicate: Close /Kills the seesion when close the browser or tab Is there a solution for cross browser event. I need to check if user closes their window and to throw an ajax request to my database to sign them out. I've looked everyone but most cases its not working in all browsers. Anyone have a solution? Or Alte...