javascript

dynamically creating object with properties in javascript

I know how to create simple object and add dynamically properties to it. object = new Object(); object.someproperty = ""; However, I'm having hardtime creating dynamically something like this: (in javascript) var datasets = { "usa": { label: "USA", data: [[1988, 483994], [1989, 479060], [1990, 457648], [...

JQuery Tooltip Plugin from Jorn

I am thinking someone may have run across this one, but not sure. From a high level, I am trying to roll over a input [type=text] and display a tool tip (with the contained value) using the plugin available at http://bassitance.de. I have to use titles and classes for validation on the specific elements, so I put a blank div to hold ...

How do I load binary image data using Javascript and XMLHttpRequest?

I was trying to load an image client side and base64 encode the bytes returned by the server in order to pass it off to perform some processing. IE has a RequestBody property of the XMLHttpRequest object, but I can't seem to use it, and RequestText is truncated. In Firefox, RequestText is there, but seems corrupted. ...

Javascript - HTMLCollection to string using prototype.

Hi I am trying to update a div with some html from another div. var results = document.getElementsByClassName("myclass"); $("resultsDiv").update(results); I then get this: [object HTMLCollection] How do I convert it to a string so it is shown as html in my div ? Cheers ...

paste excel data into html table

Using Javascript, how do I create an HTML table that can "accept" numeric matrix data from excel (or google spreadsheet), via "copy" in the spreadsheet and then "paste" into the table in the browser. Thanks. ...

Replace selected text with jquery/javascript

I am trying to build a specialized WYSIWYG text editor in the browser, and have a very limited set of functionality, but the biggest part of that is wrapping certain text in span tags. I can find many resources explaining standard stuff (execCommand and whatnot), but have looked and looked and can't find anything to do what I need. Bas...

JavaScript or jQuery string ends with utility function

what is the easiest way to figure out if a string ends with a certain value? ...

How do I use multiple selectors in jQuery?

I am using the following code to apply a hover effect to a set of images within a div called toolbar: $("#toolbar img").hover( function() { this.src = this.src.replace("_off", "_on"); }, function() { this.src = this.src.replace("_on", "_off"); } ); But I also want to apply the same effect to a d...

Using Javascript to send an HTTP attachment to the user (open browser's Save as... dialog)

I'm new to web development, so I apologize if this question is noobish. I want to serve a file that is on the server's hard drive to the user when requested (ie, send an HTTP attachment to trigger the browser's "Save as..." dialog) in Javascript. The user clicks on a button on the page, the server generates a customized data file based o...

How to Get Values from jQuery Select Slider?

I'm using the Filament Group's jQuery Select Slider to produce a form for selecting a range of specific values. How can I get the values of the slider and update <input> field? $(function(){ $('select').selectToUISlider({ labels: 7 }); //fix color fixToolTipColor(); }); I understand that I can get the values throug...

How do I use Scriptaculous's Effect.Morph to turn off a class?

Scriptaculous's Effect.Morph can take a CSS class and apply it over a period of time. I have a div which expands when a button is clicked, so it uses Effect.Morph to apply an .expanded class. Now I'd like to remove the .expanded class on a second click, toggling the div closed again. How can I invoke Effect.Morph to do that? ...

How to set the function to make user click the table header to change sorting order

I want to let user click the table header to sort the table, but can just set the ascending order, can not set the descending order in the same table header. following is the function I used, just want to know how to call the function function sortDistrictNamedescend($a, $b) { if ($a->DistrictName == $b->DistrictName) { ...

Firebug doesn't load JavaScript files or stop execution on breakpoints

I'm new to Firebug and having a lot of trouble. JavaScript files usually show up empty, or load partially (some of the time) Lines are not available to set breakpoints on frequently (line numbers are greyed out) When I do set breakpoints, script execution often does not stop on them I'm using Firebug 1.3.3 and Firefox 3.0.11. I have ...

add a button link to lightbox 2

Hi, I need to add a button link to lightbox 2. I have added the code to the title attribute of the anchor and while this works well, the code shows in the hover tool tip. I read a recent question where the answer was to modify line 398 of lightbox.js as follows: 398: imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAtt...

detect when all events from a mouseevent have fired?

I want to know when all of the events for a mouse event have fired. For example, if I have registered listeners on document and an element, then click the element, i could get multiple events firing (more if the resultant events are bubbling). How would i know when all events resulting from that click have completed? This site provide...

Learning JavaScript... Should I skip straight to the good stuff (the frameworks)?

I learnt HTML/CSS a good few years back, then PHP a little later. I've recently become interesting in web development again, just started playing with frameworks like Django and RoR. I'm curious as to how much time/effort I should spend learning straight JS before looking at frameworks. I've been reading through a let of articles called ...

Options show step by step based on users' choices

I want to build a survey which has about 20 questions. All questions are in the same page. The structure of whole survey is like the tree structure. Initially, only one question is shown in the page. if user chooses option 1,2 of question 1, the survey ends. if user chooses option 3,4,5 of question 1, then question 2 appears. if user...

javascript object oriented function invoke beginner question

Hi, i got a question when create a javascript object, when one function invoking another function within the object, do we need to use 'this' MyObject = function() { this.function_one = function(param) { return param + param; }; this.function_two = function(param) { return this.function_one(param) * this....

How to trigger this event?

I have a table with 3 x 3 cells. Each cell contains a button, in 1-9 when click on any button, the value will be appended to an input textbox. I tried to trigger the onmouseout event in the table but not work. and I also tried to add a div outside the table, and capture the onmouseout event. How to use javascript to trigger that weathe...

I need to upload Open Flash Chart 2 image to servlet

How can I upload image with JavaScript from Open Flash Chart 2 to servlet? What I have to implement so that I can save that image to my server ? ...