javascript

Swap CSS style of a group of elements on click

I found a thread, http://stackoverflow.com/questions/195951/change-an-elements-css-class-with-javascript, that is along the lines of what I'm going for, but I don't know how to implement it. I have a page with 4 input buttons and two CSS styles: "Selected" and "notSelected". One button will be hard coded initially as "Selected". When ...

For textbox/textarea limit the length of input on typing, but not on paste.

Hello. I got a strange requirement: function TextLimit(elem, maxChars) { ... } Where elem is a textarea or input of type=text and maxChars is the maximum number of characters that could go into the elem. The code inside the function must limit the length of the text inside elem to maxChars when the user is typing. However, if the us...

Allowing decimal in numbers only field with JavaScript

Hi all, I have a function which I use to limit form inputs to numbers only, or number and decimals depending on the field. Allowing decimals and numbers is easy enough, but I am trying to take it a step further and allow only one decimal, while also making sure that decimal is not the first character in the field. I have successfully a...

Resizing Page Elements based on Window size

Problem: My Client wants me to create a launch webpage for his product such that there should be no scroll on the page, be any browser or window dimensions. Doubt: Is this possible using CSS and Javascript? Some Early Diagnosis: This might be a little similar to this or this but the difference is that I want to resize the dimensions of...

Using a dynamic variable within a for statement

I would like to dynamically create and reference some variables on the fly, but i'm not understanding how to. Here is what I would think 'should' work, but I know doesn't. var weeks = 4; for(i=0; i<weeks.length;i++){ var 'week_'+i = valueFromXML; } function wtFn (){ 'week_'+i.splice(-1, 1); if('week_'+i.length <=0){ $(thi...

What are the best light-weight solutions for Drag and Drop?

I love and use jQuery quite a lot, but I am hoping to find an alternate solution for a special project. I am creating a bookmarklet which will interface with my application to allow users to enter information much quicker. One of the greatest pains in my application at the moment is uploading images. Users (understandly) hate the proces...

Check whether it's safe to iterate over a JavaScript variable

I have a JavaScript function where someone can pass anything in, and I iterate over each of its keys using the for x in obj syntax. However, this results in an error if they pass a primitive (string or number); the correct behavior is for the function to act the same way on those as it would on an object with no keys. I can do a try....

Can code in a Javascript file know its own domain/URL

If I have a site, example.com, and a page on that site references a Javascript at subdomain.example.com/serveAd.js -- is there a way from within serveAd.js to know its own URL, or the domain from which it was downloaded? (The JS can certainly know all about the page that called it. I want to know if the JS knows about its own origin.) ...

How to get javascript call trace of a webpage

Can someone tell me how I can get a call trace between different javascripts? Suppose I have an html page that loads some javascript files, which in turn may load other javascript files from the server. Is there a way that I can trace which js page is loaded from what other js pages? I've used google chrome speed tracer extension, and...

tinyMCE triggerSave not working

Im trying to submit a form with a tinyMCE textarea. Im submitting the form via javascript, and in order to do this i know you have to call tinyMCE.triggerSave to copy the contents of the editor to the hidden textarea it replaces. For the life of me i can NOT get tinyMCE.triggerSave to do ANYTHING. I know its not because i run the command...

Slide instead of Fade for a div

This could be a simple thing im sure... Im trying to get the fade to slide: $slides.eq($btns.index(this)).fadeIn().siblings().hide(); At the moment it works great with fade, i just need this line tweaked to slide, ive done the obvious but i must be doing something with the syntax as it doesnt work. Cheers in advance! //added var $b...

mongodb and mongomapper

hi i have a rails app that currently uses activerecord to store and query products. Each product has a category and sub category and each sub category is defined by multiple field that i can create within the application. From this when a user wants to input a specific product, they are pressented with the relevent form fields. This ...

Accessing GPS data on LG VX8360 phone

I am trying to design a web page that provides content depending on the user's location. I made a simple page that tries to access the navigator.geolocation object and report whether it exists, and if it does, the latitude and longitude reported by the browser. I tested it on my home computer, which is running Firefox, and it worked fine...

Fill available spaces between labels with dots or hyphens

Hello everyone, I have a page with labels which are contained in a div, the labels has a variable with and i want to fill spaces between both with characters, dots or '-'. For example. My label text 1 ----------- Some Text Here. My text 2 ----------------------- Another Text. If you notice both text are justified (or at least i tr...

Keeping track of asynchronous calls

Hi, I'm working on a Mozilla extension, and have a problem where I make n calls to an asynchronous function, that function is out of my control and it executes a callback on completion. In this callback, I need to take a special action if it's the n'th & final callback. I can't work out how to determine if a callback is the final one, I...

asp.net mvc javascript server variables

I would like to send the following from JavaScript, because I am using Flash FSCommand to communicate between two views: Url.Action("Testing", new { FlashName = "flash.swf" } Testing is the view and Flashname is the variable I am using. The JavaScript should receive a command and arg from Flash movie.(e.g. command play with arg o...

Convert Json date string to JavaScript date object

Hi, I have the following JSON object which has a date field in the following format: { "AlertDate": "\/Date(1277334000000+0100)\/", "Progress": 1, "ReviewPeriod": 12 } I want to write a regular expression or a function to convert it to a javascript object so that it is in the form: { "AlertDate": "AlertDate":new Dat...

Draw image from pixel data arrays

If I have an array of pixel data in JavaScript, is there a good way to display it on an HTML page? On recent versions of Safari and Firefox, I can make a <canvas> element and use putImageData to display the pixels, but ideally a solution could work on older versions as well and more importantly, work on Internet Explorer. Another solut...

disable onmouseout function when onclick event is activated

My code looks like this using Image Swap of Dreamweaver. <a href = "#"> <img src="images/leistungen.png" alt="leistungen" name="leistungen" width="162" height="38" id="leistungen" onclick="MM_swapImage('home','','images/home_orig.png','philosophie','', 'images/philosophie.png','kontakt','','images/kontakt.png','body_layout','','images/...

Decent JavaScript mask for floating point numbers

Hello people, I'm developing a system in ASP.NET and I need a textbox mask to handle an input of floating-point numbers. I haven't yet found a javascript mask that would RESPECT the decimal point. I've tried several, including dFilter and "Mask JavaScript API" and none of them could do the job in a swift manner. The numbers I need to d...