javascript

ExtJS: How can I prevent the sum of number columns in a GridPanel from going over a given maximum?

I have a GridPanel with just two columns: names and commission percentages. The sum of all of the percentages should never exceed a predetermined maximum (say that 25% of the sale is up for grabs). Name Commission Bob 10% Sally 15% (Maximum is 25%) Everything is fine. I’ve attached a custom validator (se...

Mapping a String to an Array

Given a string delimited by commas, how would I go about splitting it into an array in javascript? ...

passing a function as a parameter?

Here is my event and as you can see I want to send a function with it as a parameter. onclick="deleteItems('image', 'size', function(){GetImageSize();})" The delete function is in a js file. In my js file I want to call my GetImageSize() function. var deleteItems = function(module, controller, callback) { callback(); // ??????????...

AES in javascript that matches PHP's mcrypt

Is there any javascript libs that lets you encrypt and decrypt 256 bit AES the way you do it with mcrypt in PHP (and get the same result of course)? I want to give it a variable-length message and a 32 chars key. All libs i find wants fixed-length blocks of cleartext and byte-arrays of keys... This is how it's done in php: $iv_size = m...

JS: functionname("yes/no");

I want to put my two functions into one. They look like this now: function MeYouFriend(){ $.ajax({ type: "POST", url: "misc/AddFriend.php", data: { mode: 'ajax', friend: 'ignore', uID : $('#uID').val(), fID : $('#fID').val() }, success: function(msg){ $('#friendsPop').jGrowl('close'); ...

Javascript code error in IE6

I have this piece of code on a php page, at the bottom: window.opener.location.href="/index.html"; setTimeout("self.close();",3000); This doesn't seem to work in IE6 (haven't tested any other IE version yet). It works fine in FF, Safari, Opera, Chrome etc... But as usual, IE struggles. So, what could be the problem. The error messa...

Javascript Date decorator for accurate client side time

I'm currently working on some Javascript to synchronize the client side clock with our servers. I'm doing this by looking at the 'Date' header of any Ajax responses (it only has to be accurate to a few seconds). To make the rest of the code work seamlessly with this Date function I want to override the native Date function in a decorato...

Form onSubmit determine which submit button was pressed.

I have a form with two submit buttons and some code: HTML: <input type="submit" name="save" value="Save" /> <input type="submit" name="saveAndAdd" value="Save and add another" /> Javascript: form.onSubmit = function(evnt) { // Do some asyncrhnous stuff, that will later on submit the form return false; } Of course the two subm...

what is the difference between $("#context .searched") and $(".searched",$("#context"))?

I had that question in mind for a long time. Theoretically, jQuery core function accepts an optional value that can be a DOM element - $(".searched",$("#context")[0]) - or a jQuery object - $(".searched",$("#context") ) . I discovered that last question reading that fine article. But i really cant see the difference between use a cont...

Extending native elements in JavaScript via prototype?

Would you consider extending the native elements via the prototype dangerous? I see some frameworks such as Prototype doing this so I have started to wonder if I dare to do that too. I am worried about implementing things like addClassName and make it collide in the future in a way that I can't resolve any other way than rewriting the ...

have any mistake with my last-child selector?

$(function(){ $("#mainContainer #container:last-child").css("background-image","url('/images/content-title.png') no-repeat") }) code above didn't work , nothing happend $(function(){ $("#mainContainer #container:last-child").css("background-image","url('/images/content-title.png')") }) code above work , but it change all the #...

Minifying Prototype introduces an error?

Hello all, I have made use of several web based minifiers that have worked for me in the past. I have just tried minifying a prototype version 1.6.0.1 - I have placed the original here and the minified here. The error I get from firebug after the js file being minified is this: missing } after property list ept': 'text/javascript,text...

Javascript comment stripper

I'm looking for some tool to remove cooments from Javascript sources. I was able to Google some, but none of them satisfied the following requirement: Everything else should be left as it is, in particular white space is not removed, BUT if a comment takes a whole line, the line is removed too. Shortly, I want to be able to go from a ni...

How to send an image from a Java Applet to JavaScript?

Hello, I have a Java Applet that is generating an image. Ultimately, I would like to insert the image data into a database, so I want to temporarily store the image data in a form field on the page containing the applet. I am hoping to do this without storing an image file on the client machine. This all comes from a signature pad. Her...

Jquery insert new row into table at a certain index

I know how to append or prepend a new row into a table using jquery: $('#my_table > tbody:last').append(html); How to I insert the row (given in the html variable) into a specific "row index" i. So if i=3, for instance, the row will be inserted as the 4th row in the table. ...

How to join two jQuery element objects? .add() isn't working...

Hi all, I'm inside a function and I need to return a jQuery object with two elements. Inside the function I have, for example: function getInput() { $hiddenInput = $('<input type="hidden">'); //(other code) $select = $('<select></select>'); //(other code) $hiddenInput.add($select); return $hiddenInput; } And ou...

Facebook gives "Unsafe JavaScript attempt to access frame with URL" error in Chrome

My sample Facebook app was working great yesterday in Chrome. The page integrates Silverlight ad Facebook via the JavaScript SDK. I can check basic login status, login to Facebook, get your name and log out. Today, with no changes on my part, it's broken in Chrome with a JavaScript error that's very common on Google search results, but ...

is it possible to insert a line break in this tooltip?

i have a pretty map of the US: http://upload.wikimedia.org/wikipedia/commons/a/a5/Map_of_USA_with_state_names.svg i would like to implement a tooltip with multiline functionality such as here over the red square: http://www.carto.net/papers/svg/gui/tooltips/ please help me get started on this. i will be offering a maximum bounty on t...

JSON Array Not Decoding With Eval

I have two files, one containing an array in PHP that is echoed via json_encode, and the other full of javascript functions for a webpage. One such function, that looks like this (and is unfinished): /* * Function: selectVictim * Called from function laserOn() * * Selects a random victim from a list of victims * * @return String: ...

Why won't my Javascript functions work?

Hi guys, I'm trying to edit this JQuery code to work with a PHP, but for some reason, the javascript is not working properly. This is the javascript: function sel(x){ $(this).stop().animate({height:x},{queue:false, duration:600, easing: 'easeOutBounce'}) } function desel(){ $(this).stop().animate({height:'50px'},{queue:false, d...