I need to get the last element of a split array with multiple separators. The separators are commas and space. If there are no separators it should return the original string. If the string is “how,are you doing, today?” it should return “today?” If the input were “hello” the output should be “hello”. How can I do this in JavaScript?
How to: Back button support “Ajax”
I have an asp.net ajax website, it full of things happen on the same page without page reload, such as sorting records, paging,… When the user go to another page in the same site and press the browser back button, how can i make the browser save the page state to return to it with the preselected options such as
Change cursor type for an html document from javascript
Let’s say I have a javascript method that takes a little to long to finish to go without any user feedback at all. In my case it’s sorting the rows in a table element (all in the DOM; only takes too long if there are a lot of rows), but it might do anything. I want to show the “progress”
How can I get the memory address of a JavaScript variable?
Is it possible to find the memory address of a JavaScript variable? The JavaScript code is part of (embedded into) a normal application where JavaScript is used as a front end to C++ and does not run on the browser. The JavaScript implementation used is SpiderMonkey. Answer If it would be possible at all, it would be very dependent on
JavaScript equivalent to printf/String.Format
I’m looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .NET). My basic requirement is a thousand separator format for numbers for now, but something that handles lots of combinations (including dates) would be good. I realize Microsoft’s Ajax library provides a version of String.Format(), but we don’t want the entire overhead
How can I know which radio button is selected via jQuery?
I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery? I can get all of them like this: How do I know which one is selected? Answer To get the value of the selected radioName item of a form with id myForm: Here’s an example:
Associative arrays in javascript
I have this object: Its used in this way: The problem is, in the addField() function the fields array is being set correct (perhaps because a numerical index is being used to refer to it) but the other 2 arrays (labels and rules) aren’t being touched at all. Doing a console.log shows them as empty in firebug. What do I
How to load up CSS files using Javascript?
Is it possible to import css stylesheets into a html page using Javascript? If so, how can it be done? P.S the javascript will be hosted on my site, but I want users to be able to put in the <head> tag of their website, and it should be able to import a css file hosted on my server into
Get next / previous element using JavaScript?
How do I get the next element in HTML using JavaScript? Suppose I have three <div>s and I get a reference to one in JavaScript code, I want to get which is the next <div> and which is the previous. Answer Well in pure javascript my thinking is that you would first have to collate them inside a collection. So
Trying to wrap my head around custom events
I’m trying to get my head around custom events. I understand how to register and trigger custom events. However, it seems like its not possible to register truly custom events. Everything has to trace back to a DOM event like click, onload, blur, etc. Or am I wrong? For example, suppose I have an array. I want to register an