javascript

Javascript JsON get object member name

Hi Guys, this is might be a very basic question, but seems like it's not easy to find the answer. I have a Json, more or less is like: languages = { "aa":{"iso639-2T":"aar","family":"Afro-Asiatic","labels":{"language_names":["Afar"],"native_names":["Afaraf"]}}, "ab":{"iso639-2T":"abk","family":"Northwest Caucasian","labels":{"language_...

An "if mouseover" or a "do while mouseover" in JavaScript/jQuery

Is there a JavaScript or jQuery solution to run a function repeatedly (after setTimeout) while the mouse is over a DOM object? Otherwise said, is there a JavaScript "do while mouseover" (or "if mouseover")? $('someObject').bind('mouseover', function() { //Do the following while mouseover $('someOtherObject').css('...

IE won't split string with Javascript

Hi, I have the following code: $('#smallcart .plusone').live('click',function(){ var id = $(this).attr('id'); articlenr = id.split('_')[1]; }); this works fine in FF, safari, Chrome, however in IE (7 and 8) it throws an error on the split-function (this property or method is not supported by this object). if I alert the 'id'-v...

Floating point numbers and JavaScript modulus operator

Why does 49.90 % 0.10 in JavaScript return 0.09999999999999581? I expected it to be 0. EDIT: Ok, I didn't know all this stuff about floating points. Thanks. My lecturers were slacking, it seems. ...

JQuery dropdown works on Firefox but not on Google Chrome

First the code might suck as I'm new with JQuery. I have this html: <select name="numberItems" id="id_numberItems"> <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> <fieldset class="dropdownList">...

Jquery/Javascript Math: Why are these two 1 line math problems not giving the same answer?

Shouldn't these two math problems give the same answer? Brackets/parenthesis are done first, right? so it should add them all, then divide it by 2, then subtract 10. The second answer below is the one giving me the correct value that I need, the other one gives a value that's a long ways off. var pleft = $(this).offset().left + ($(t...

How do I encode a single quote so it shows up in the label of a Fusion Chart's value?

I'm getting an 'Invalid XML Data' error for any Fusion Chart which contains a ' (ie. single quote) in the label name for data. This happens even when I encode/escape the single quote. Try the following Chart Data: Obviously when unescaped (as such) we should see an error <chart shownames='1' caption='Registrant Types'> <set value...

code duplication in javascript

is there any tool to detect code duplication in javascript?? i tried "PMD Duplicate code detector" but it is not supporting .js extension. ...

Is there a way to print the Contents of a Specific DIV

I have a Pape width different DIVs and a PRINT link. I want that if the user clicks on a Print link should a specific DIV be printed not the whole page. ...

How to generate a Javascript AJAX POST method and handle it in Ruby on Rails 3.0

I want to do something quite simple. Click a button on my html javascript page which sends a bunch of data to the server using the AJAX Post method. The server uses the data sent by the POST method to generate an xml file which it then sends back to the user so they can save it. My knowledge of ruby on rails is very limited and I've loo...

cross site scripting using script tag ,change src of a script tag, can we use id for script tag

<body> <!-- some html code --> <script src='some.js'></script> <!-- some html code --> </body> The script some.js loads a form. when i press update in that form i do not submit the form instead i form a query string and want to send it as some.js?key=value Now i need to change the src of the script tag. If we change the src will i...

Strange Issue in Internet Explorer using Flex

Hi, Im using a flex plugin with a methode: ExternalInterface.call("initialize_width"); This calls a jQuery Function witch initializes the width of the window: function initialize_width(){ $("#nav_content").css("width",900); } It works perfectly on all the browsers expect Internet Explorer... It says: "'null' is null or not an ...

play mp3 javascript

Hello everybody, I am new with programming, how do play music in Java program Javascript? make like winamp A program that looks like Winamp. ...

How to JSON data using $.getJSON from a php file ?

I have a php file that receives data from mySQL table. The mySQL table 'user_spec' has only one field 'options' that it returns. Then I convert returned data into JSON, under is code doing that. <?php $username = "user"; $password = "********"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die...

"method" method in Crockford's book: Javascript: The Good Parts

Douglas Crockford wrote in his book (Page 4): Throughout the book, a method method is used to define new methods, This is its definition: Function.prototype.method = function (name, func) { this.prototype[name] = func; return this; }; Then he starts to use this method to add method in Number, String, Function, Object, Array, ...

Confirm Browser Exit/ On Browser Exit Techniques

I've been looking around for a while and haven't quite found what I've been looking for. My web page stores reports, and the user has the ability to save these reports. I'm looking for a method, using jquery or the javascript onunload/onbeforeunload to ask the user if they wish to save the report or continue without saving when the brow...

Encapsulation in Javascript

I'm pretty new to Javascript, as my SO profile will attest. I've just been reading up on a few tutorials and come across something I don't totally understand in regards to Object Orientation and Encapsulation when applied with Javascript. The tutorial stated that Javascript objects can be declared like this: var myCustomObject = new O...

Multiple Logical Operators in javascript

I want to check the following 1: Is x a number 2. If x is less that 5 or greater than 15, sound alert 3. If all is ok, callMe() var x = 10; if (isNaN(x) && ((x < 5) || (x > 15))) { alert('not allowed') } else { callMe(); } What am I doing wrong? ...

Best available guide to Sencha?

hi everyone, i'm very new to sencha and i need help with it. can anyone give me few links regarding sencha tutorials and books.... on the other day i found out a site showing info and source code about sencha. i remember it as sencha kitchen sink.....but now when i google it i couldn't find it if you know about this please help me wi...

how to check Page.Validate() on client side (Javascript) in Asp.net?

I want to check page validation on client side, like Page.Validate() but its server side method, is there any client side function which can work like Page.Validate() with javascript. ...