javascript

Javascript: Using integer as key in associative array?

When I create a new javascript array, and use an integer as a key, each element of that array up to the integer is created as undefined. for example: var test = new Array(); test[2300] = 'Some string'; console.log(test); will output 2298 undefined's and one 'Some string'. How should I get javascript to use 2300 as a string instead of...

Deselect highlighted link when webView:shouldStartLoadWithRequest:navigationType: returns false

I'm displaying some HTML with links in a UIWebView. I want the links to open in Safari after the user confirmed that the link should really be opened. Opening the link works fine, but if the user cancels, the link remains selected and is highlighted in blue. How can I deselect the link and get rid of the highlighting? - (BOOL)webView:(...

JQuery - Form Reset - Exclude "Select" box

All, I can reset all my form elements using the following JQuery Syntax: ('#myform')[0].reset(); How can I modify this to exclude the reset of "select box" values? Thanks ...

Write back to an XML file

I was wondering if this is possible, I'm not looking for code, i just want to be pointed in the right direction - php, asp or javascript. I have an xml file: <?xml version="1.0" encoding="utf-8"?> <Groups> <Group> <groupNum></groupNum> <purgeGroup></purgeGroup> <DupeRecs> <DupeRec> ...

Javascript How do i call functions from an array of function names

var action = ['function1','function2' etc ] var obj = new objectcreate (); for (functionname in action){ obj+'.'+action[variablename]+'()'; } the functions are already generated I just wanna go through an array and execute all the functions it on the object i created thanks for your help ...

Make sure first ajax function finishes before second one.

I have a JavaScript function that makes two consecutive Ajax requests using jQuery. I want to make sure that the first request has loaded before the second function is called. Is there a way I can do this? ...

if isset statement with javascript ?

În php I would use this to see if a variable is set and then use that value, otherwise make it a zero: $pic_action = isset($_POST['pic_action']) ? $_POST['pic_action'] : 0; But what is the equivalent in javascript? I want to check if an element exists in the document, and then if it does, add it to the variable, otherwise add som...

How to edit a file's properties after is uploaded

I'm using the uploadify jquery plugin to upload multiple files. Everything works fine, but i want something a little more from the script. I want to add some more info to the uploaded files. How do I remove the default behavior of the onComplete option and instead of removing the file queue item from the list, to display a thumbnail of t...

Make sure ajax function finishes before 2nd non-ajax function fires

Similar to the question I just asked, If I call an ajax function in jQuery and then a non ajax function how can I prevent the non-ajax function from firing until after the first ajax callback function has completed. Will declaring async: false in the first ajax function be enough? ...

Object and Function are quite confusing.

Object instanceof Object true Object instanceof Function true Function instanceof Object true Function instanceof Function true so if Function is an Object and the Object is a Function how come Function === Object and Function == Object are false? I do understand that checking the instance of an object is not the same as comparison....

using populated xml element from ajax

I have created a javascript object and associated method which looks very similar to this. "getUserInfo" is executed in $().ready(function(){} function userObject(userId) { this.userId = userId; this.getUserMachineList = function(infoId, machineListId) { jQuery.post(machDBPHPPath + "/listAllUserMachineAccess.php", ...

JSONPath :contains filter

Hey all, I was wondering if any knew of a way to use a regular expression or wildcard operator (or pehaps '%LIKE%' in SQL) so I could use JSONPath to do searching within a large set of JSON data. For instance (and yes, I'm parsing, not eval( )ing my data in the app): var obj = eval ( '({ "hey": "can you find me?" })' ); And I'd like ...

ASP.NET MVC 2 RC - client side validation using Data Annotations fails with multiple attributes

I'm having trouble with the JavaScript being emitted for client side validation when using Data Annotations on a model. Here's a sample of a model that works just fine with two required fields followed by the JavaScript that's emitted: public class LoginUserViewModel { [Required(ErrorMessage = "Email required")] pub...

Is there a sane reason for this IE array.push bug?

Note: Edited the sample to reflect my actual problem, which was a trailing comma in the array initialization. Seems that a mixture of raw array initialization and array.push can cause the indexes to get all whacky. I do this: var iFeelLikeIt = true; var items = ["thing1", "thing2",]; if (iFeelLikeIt) { items.push("thing3"); } items....

How to Change a Value in a JavaScript Array of Multiple Values

I have a JavaScript array that can be built using this code var Test = []; Test.push([3, 2]); Test.push([5, 7]); Test.push([8, 1]); Test.push([4, 10]); What I need to do is change the first value in each item to be in order from 0, the result should look like this: [0, 2] [1, 7] [2, 1] [3, 10] I will also accept a jQuery answer. ...

asp mvc - what is the best way to dynamically add data controls

Scenario: I have the following structure; Group (parent) -> Item (child). A Group can have many items. both group and item only have one editable field (string) In other parent/child table data I have used a partial view to display both the parent and child data - with the child data being a standard MVC index (i.e. list of items wit...

How to create an empty jQuery result

I need to loop through an array and create a number of elements which I want to have in a single jQuery result object. for (var i = 0; i < 10; ++i) { $myJQueryObj = $myJQueryObj.add($("<span>blahblah</span>")); } The problem with this, however, is that you need a jQuery object to begin with, and you obviously want to start it empt...

javascript float from/to bits

Hello, I am trying to perform something that is brain-dead simple in any other language but not javascript: get the bits out of float (and the other way around). In C/C++ it would be something like float a = 3.1415; int b = *((int*) and vise-versa int a = 1000; float b = *((float*) In C# you can use the BitConverter ...floatBits...

JavaScript Form validation in IE

Hi all I am working on a contact or phone book application. So currently I am working on searching for records. Now I have this form with certain elements/fields being required or mandatory while others are optional. So I wrote a very simple javascript function to check if those required fields are missing or not. It works greate on fi...

Editing draggable after it's added to a sortable

Hey, I'm trying to work out what event I need to bind to and what property I need to use to get a reference to the DOM element for the dropped item (That is the item in the receiving list. Here's what I have so far... <ul id="toolbox"> <li>A</li> <li>B</li> <li>C</li> </ul> <ul id="existing"> </ul> <script language="javascr...