javascript

JavaScript: Rounding question

If I have the following var lowerBound = 0; var higherBound = 100; var inputVar = document.getElementById('input').value; // e.g. 51 How do I programatically determine if the inputVar is closer to variable lowerBound or variable higherBound? Meaning, if the user inputs '51', the function should return '100'. But if the user inputs '...

How might I extract the property values of a JavaScript object into an array?

Given a JavaScript object: var dataObject = { object1: {id: 1, name: "Fred"}, object2: {id: 2, name: "Wilma"}, object3: {id: 3, name: "Pebbles"} }; How do I efficiently extract the inner objects into an array? I do not need to maintain a handle on the object[n] IDs. var dataArray = [ {id: 1, name: "Fred"}, {id: ...

Render page initially and update via AJAX using the same template HTML

Let's say you have a view called "View Story" which is just a web page rendered on the backend via Python/Django. On that page there's a list of comments at the bottom rendered as part of the "View Story" template using Django's templating system (in a loop). This page also allows you to add a comment to the list. This is done through...

JavaScript: convert to currency format

Is there a built in function of JavaScript to convert a string into a current format? For example var a = '1234'; a.convertToCurrency(); // return $1,234 UPDATE Please note that I want the function to return the currency to include the US comma to group digits. ...

jQuery to hide all row classes except 'row2' only when the parent class is viewContainerTop

I've been to jquery select class inside parent div and Testing objects for ancestor/descendent relationship in JavaScript or Jquery and jQuery wild card character but can't seem to fit the pieces together. Thanks. <div id="viewContainerTop" class="top"> <div class="row1"></div> <div class="row2"></div> <div class="row2"></div> ...

Why does a non-dynamically created iframe shim show, but a dynamically created one does not?

I have a custom control that is made up of a text field and the ajax control toolkit dateextender. In IE6 I'm hitting the z-index bug where the calendar is showing behind select boxes. If I have the shim sitting in the control, initially hidden, it seems to display fine when the calendar is shown, but when I try to dynamically create t...

javascript error: "data.getElementsByTagName is not a function"

Hi, I've spent hours on this stupid error, so any help would be appreciated! I'm using Jquery to request xml from a python file hosted on google appengine. I'm then trying to process the xml. Here's the response to the post request obtained from firebug: <?xml version="1.0" encoding="ISO-8859-1"?><building key='agdhcHRydXNochALEglCdWl...

jQuery to hide all classes that start with 'row' except ‘row2’ only when the parent class is viewContainerTop

A variation of this question... <div id="viewContainerTop"> <div class="row1"></div> <div class="NotRow1"></div> <div class="row2"></div> <div class="row2"></div> <div class="row2"></div> <div class="row3 first"></div> <div class="donthideme"></div> <div class="row4"></div> <div class="row5"></div> </div> ...

stack overflow error

i just got my first ever stack overflow when I ran this script: var hlat = 0.00; var hlong = 0.00; var mapdiv = document.getElementById('map'); var map_url = base_url + 'ajax/getPropMap'; var id_url = base_url + 'hotels/gethotel_id'; var id=0; var map = null; // apply gmaps to product map div $(function(){ $.get(id_url, {id: segmen...

Is it possible to use d8 to measure memory usage?

With the release of the Closure compiler, I was hoping to see if there was a difference in memory usage between a js file using the compiler and one which had not. In particular, on a mobile platform like Palm's WebOS, the very limited amount of memory available means that every little bit will help. EDIT: I should point out that d8 i...

Reverse order of operations for OnClick and OnClientClick?

I have some simple javascript that I'd like to run when a button is clicked, but I also want some postback action to occur on the server. The logical code for this looks like this: <asp:Button ID="btnOK" runat="server" Text="Save Changes" OnClientClick="UpdateParent();" OnClick="btnOK_Click" /> <asp:Button ID="btnCancel" runat="server"...

jQuery / javascript question, is a click handler executed asyncronously?

if I have $("a#foo").click(); $("a#bar").click(); dostuff(); and both have click handlers attached which do different things..is it guaranteed that bar's click handler will only execute after foo's completes? or are they dispatched asyncronously similarly..will dostuff() only execute after foo and bar's click handlers complete? ...

Translate user selected text with Google Translate API (and jQuery)

I am working on some JavaScript for a website with content in multiple languages. I would like to use the Google Translate API to allow the user to select a word (or phrase) and have a translation automatically provided. For the time being, I'm simply having it alert the result for testing. This is what I have so far: google.load("l...

Jquery Cycle + Firefox Squishing Images

Hey guys, I'm running jQuery Cycle for an image gallery. View the link: Here My problem is that the images are getting squished when viewed in firefox. The problem disappears when I re-load the page. This leads me to believe that the Javascript is triggering before all the images are loaded (usually the first image works fine and the re...

IE caching WCF results - can I fix that somehow?

Hi All, I have a WCF service in an ASP.NET AJAX app that is returning json. Im using MS AJAX and the client PageRequesManager to run the service after each endRequest for any partial page updates. The user has a form, they update data and submit and the service needs to grab the latest data. When I debug using FF and FireBug, everything...

Randomizing output in this javascript

Hello! I would like to randomize the output of the numbers at the end of this script. Right now it creates a list of random image names sorted by number, I would like to have the image names shuffled. Any suggestions? I'm new to JS and pulling my hair out over this. Thanks! function check(value) { if ( value != Math.round(value) ...

Google Analytics Event Tracking As Client Side Error Log

I'm currently using Google Analytics Event Tracking to track user interface interactions in my web application. Since our system doesn't currently have a way to log client side errors, as a quick fix I've put event tracking code in catch blocks and web service error handlers. Does anybody else do this? Is it effective, or would you re...

How to detect Flash full screen mode and escape from it with JavaScript

I need a way to send notification to the browser that my website user has entered full screen mode in Flash. On clicking a link running only JavaScript within flash it escapes full screen and completes the rest of the JavaScript. Any ideas? ...

how to store blob data in sqlite database from javascript with google gear ?

Hi, We have a very special requirement to store blob data in SQLite database, where We have to store documents. We have static html page which is in user disk, so we want user to upload document without connecting to internet with help of google gear, javascript and SQLite. is it possible to do ... Any Help Appreciated ... ...

Can we make Print button without JavaScript?

Can we make Print button without JavaScript? to open browser print window. ...