javascript

Search in a two dimensional array and return the array list as a array

How can I search in a two dimensional array and return the array list as a array? var dataSet = new Array(new Array()); function searchAsset(){ dataSet.length = 0; var fileName = document.getElementById("fileName").value; var arr = new Array(["view_page.psd","test"],["ok_test.jpg","yes","kk"],["new_banner_2009.fla","good"],[...

XQuery execution without a software

How can we execute Xquery embedded inside Html or with a reference to an xquery document within html? is there a JavaScript method ? or ASP DOM method ? ...

weird jquery problem in IE8/7

hello. the problem starts when i use #mydiv{ margin:0 auto; } all other browsers just works fine. this is an example alert($("#mydiv").position().left); //output 0 $("#mydiv").animate({'left': '-=500'}); alert($("#mydiv").position().left); //output -499 how can i solve that? is it a common ie problem? is there any solution fo...

Form submits twice when pressing return/enter

I'm using anchors as links, and also I'm binding the enter/return key to submit a form, like this: $("form[name!=smsform]").bind("keyup", function(e){ if(e.keyCode == 13){ $(this).submit(); }); $("a[title=submit]").click( function(){ $(this).parents("form").submit(); }); However the form submits twice when clicking enter/return using...

Creating a JSON Tree from a string hierarchy

Given these 4 variables, var el1 = {name:'ronaldo', team: 'europe/spain/realmadrid'} var el2 = {name:'messi', team: 'europe/spain/barcelona'} var el3 = {name:'gerald', team: 'europe/england/liverpool'} var el4 = {name:'unknown english', team: 'europe/england'} I need to produce this JSON tree hierarchy, { "text":"europe", "le...

Multidimensional Array cloning using javascript

Hi, I want to make a clone of multidimensional Array so that i can play arround with the clone array without affecting main Array.i m using following function to do so, Array.prototype.clone = function () { var newArray = new Array(this.length); for(var i=0; i < this.length; i++ ){ newArray[i] = this...

jQuery under SVG

Is there any way I can run jQuery under SVG instead of HTML? I know about jQuery svg plugin but this is not what I want. As for now the jQuery engine contains some statements like this: div = document.createElement("div"); div.style.display = "none"; It fails with exception during jQuery initialization under SVG because SVG docume...

Why does javascript change primitive types when passed into function.apply() or function.call()?

It seems that when using a primitive type (string, number) as the this subject of a function call (as the first argument to either function.call() or function apply()), the primitive type is promoted to its object equivalent (e.g a string turns into a String). To illustrate: var f = function(x) { return [typeof(this), typeof(x)]; } v...

How to set the text of a submit button using JQuery?

For some reason... $("#thebutton").val("New text") doesn't work. ...

Filter 2 different nodes in E4X?

Can I filter 2 different node types in E4X same as attributes but then on node type? I cannot find this anywhere: Something like": $.book_xml.pages.page.(node == 'front' && node =='back'); <pages> <page> <front></front> <back></back> </page> <pages> ...

JQuery timer, how do I do this

Is there anyway to implement a timer for JQuery, eg. every 10 seconds it needs to call a js function. I tried the following window.setTimeout(function() { alert('test'); }, 1000); but this only executes ones and then never again. ...

JavaScript regex replace - but only part of matched string?

I have the following replace function myString.replace(/\s\w(?=\s)/,"$1\xA0"); The aim is to take single-letter words (e.g. prepositions) and add a non-breaking space after them, instead of standard space. However the above $1 variable doesn't work for me. It inserts text "$1 " instead of a part of original matched string + nbsp. Wh...

Why does jQuery fail to hide certain HTML?

I've been running my head into a wall trying to figure this out. Take the following HTML body: <body> <div id="project"> <h1>Hi</h1> <h2>Hello</h2> </div> </body> And the following jQuery code: $(function(){ var h = $('#project').html(); $('#project').remove(); $(h).hide().appendTo('body'); alert("Created HTML, hide, and ...

Disabling elements when deselecting a checkbox

Hi, I have a checkbox, a drop down list and a text box. I want to disable the drop down and text box on deselecting the checkbox. Following is what I have on my view - <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <%Html.CheckBox("chkCheckMe", new { enabled = Convert.ToBoolean(ViewData["ShowFlag"])}); %...

RadComboBox, how to get selectedItem

Dim sb As StringBuilder = New StringBuilder() sb.Append("<script language=javascript>") sb.Append(" function SetValueInBody() {") sb.Append(" var _dllGetDynamicFieldKey = $find('" + _dllGetDynamicFieldKey.ClientID + "');") sb.Append(" alert('Set Value: ' + _dllGetDynamicFi...

Storing selected row in array in JavaScript

How do we stor selected row in array in JavaScript? ...

How do I make a div slide up and disappear in JQuery?

And just...poop, HTML gone. How do I do that? thanks. I know about .hide() , but..I want permanently gone (for that one page), and slide up. ...

javascript function scope

Who can explain why result are [20, 20, 10, 10] in this code: var x = 10; var foo = { x: 20, bar: function () { var x = 30; return this.x; } }; console.log( foo.bar(), (foo.bar)(), (foo.bar = foo.bar)(), (foo.bar, foo.bar)() ); Links to specification are welcomed ...

Replace javascript on a site with Greasemonkey

Hello, does anyone know how to replace JavaScript on a site with Greasemonkey ie. This is the default code: var Test="1"; And i want to replace it like this on the page load: var Test="2"; Thanks in advance! ...

How do I have an input button and <a> tag?

I have this: <a> Stuff stuff stuff <input type="Submit" onclick="...."> </a> The problem is...when I click the submit button, it goes to the instead of onclick. ...