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 '...
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: ...
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...
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.
...
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>
...
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...
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...
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>
...
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...
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...
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"...
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?
...
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...
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...
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...
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) ...
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...
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?
...
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? to open browser print window.
...