javascript

Limiting number of lines in textarea

Hi, I'm looking for a javascript that can limit the number of lines (by line I mean some text ended by user pressing enter on the keyboard) the user is able to enter in textarea. I've found some solutions but they simply don't work or behave really weird. The best solution would be a jquery plugin that can do the work - something like C...

Hiding entire table resizes it

Having an HTML page with a simple table and js code to do show / hide on it: <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <title>title</title> <script type="text/javascript"> function showErrorSteps() { var el = document.getElementById("t1"); if(el.style.display=="none") { ...

Javascript Not Firing after Dir Reorganization

Ok, so here's the situation. I'm working on a site that allows people to upload things to a database that are then pulled to the frontpage so people can see them. It is a pretty straightforward site and I had it working real well but i was developing everything at ../html/backend for the sake of simplicity and to make sure nothing was s...

prototype javascript calendar with customizable rendering of cells like YUI Calendar

I already make extensive use of prototype and don't want to add an extra framework like YUI. I need a javascript calendar which enables me to customize rendering of calendar-cells on a cell by cell basis. (For rendering events, prices, etc. on a certain date) . YUI Calendar makes this possible, but I already make extensive use of pro...

JQuery methods and DOM properties

I am confused as to when I can use the DOM properties and when I could use the Jquery methods on a Jquery object. Say, I use a selector var $elemSel = $('#myDiv').find('[id *= \'select\']') At this point, $elemSel is a jquery object which I understand to be a wrapper around the array of DOM elements. I could get a reference to the DO...

Any way for a Google Maps placemark to trigger a script in the page that contains an embedded map.

Is there any way to have a map's placemark call a javascript method on the page that contains the map. For example: Say we have a google map that has pins for our customers. If the sales operator clicks on the pin of CompanyA, could the containing page use javascript to identify that ConpanyA's pin had been clicked. And show a quick rep...

How to prevent a user from having multiple instances of the Same Web application

I'm wondering if it is possible to determine if a user already has a web browser open to the web application I'm working on. It seems that they can open several instances of the same web app and click on buttons to read information that they have used before to enter into an input screen that they're currently working on. What happens t...

How to prevent iframe from resizing parent window?

I have a page with iframe. Content inside iframe does window.parent.resizeTo calls (or something similar that in result resizes whole browser window). It does so to accomodate for its contents. I want to prevent resizing of whole browser window and just change the size of iframe element instead. Is there a way to intercept these resize...

How to set DIV width/height with Javascript in Firefox

The following works in IE, but not Firefox: var el = $get('divToMask'); var box = Sys.UI.DomElement.getBounds(el); var maskEl = $get('maskDiv'); // Only seems to work in IE maskEl.style.width = box.width; maskEl.style.height = box.height; Sys.UI.DomElement.setLocation(maskEl, box.x, box.y); box.width and box.height contain the corr...

How to dynamically call a php function in javascript

Hi guys, I have an index.php with the following js function: function returnImageString() { return "<?php include 'inc/image.functions.php'; echo getRandomImages(7); ?>"; //This isn't dynamic; this will always return the same images. How do I fix this? } However, when the page loads, the php script is called and the result...

How can I highlight a subset of the text in an input box?

I'm trying to figure out if it's possible using Javascript to highlight a specific range of data in a text field. textfield.select(); That ^^ works to select the entire text, but for all my googling I haven't stumbled upon a way to select, for example, characters 2 through 10 of the entered text. Is this possible? Thanks! ...

Passing Hebrew encoded text by AJAX (windows 1255)

When making an AJAX call from the client, the server responds with Hebrew text. The PHP page that returns the result is in Windows-1255. For some reason, the result encoding is not Windows-1255, and all I see is gibberish instead of Hebrew. The result purposely contains HTML tags. I've tried urlencoding, base64 encoding, nothing works...

Dynamically fill in form values with jQuery

I know how to do this with pure PHP but I need to do this without reloading the page. Is there anyway with jQuery to effectively pull back some database results (based on what a user has input in the first text field on a form) then populate some of the remaining fields with data pulled back from a db query? Essentially I would like to...

How to serialise on object to JSON in Javascript

I'm a Javascript newbie so bear with me. How can I serialise an object to JSON in Javascript? Is there a common external library I can use? I'm aware of jquery.getJSON(...) but this doesn't seem to quite do what I want, which is to simply get a string containing the JSON for an object in a piece of Javascript. ...

Reorder Divs

How would I go about reordering divs without altering the HTML source code? example, I want divs to appear in order #div2, #div1, #div3, but in the HTML they are: <div id="#div1"></div> <div id="#div2"></div> <div id="#div3"></div> Thanks! ...

How can I monitor users clicking on links via Javascript?

I've been tasked with determining if it's possible to detect link clicks with javascript. I'm aware of the onclick attribute, which gets me part of the way there. Other then that, I don't know what the best approach is. I've already told my boss that it will likely involve some form of ajax, which probably involves a big library, which...

Javascript: What's more efficient, IF block or TRY/CATCH?

I'd love some other opinions on what's more efficient in this code. Basically in the following code, there's a setInterval loop and I need 4 requirements to be true before the code runs in the loop. So in v.1 I wrote an if statement checking all 4. Worked fine. Then I switched to just using try/catch, with the code I want to execute sit...

Iterating through list of keys for associative array in JSON

I have an associative array in JSON var dictionary = {"cats":[1,2,37,38,40,32,33,35,39,36], "dogs", [4,5,6,3,2]}; Can I get the keys from this? I tried in Visual studio putting a breakpoint but can't see any property that represents keys. Is it not possible? I'm fine creating a separate array if necessary, but was just hoping it wasn...

"method overloading" in javascript

So I admit that I'm new to javascript and that I come from a C.+ background ("Hi, I'm Bob, I'm a class-based static language user", chorus "hi Bob!"). I find that I often end up writing functions like: function someFunc() { if (arguments.length === 0 ){ ... } else { ... } } (where there might be three such c...

How to convert a currency string to a double with jQuery or Javascript?

I have a text box that will have a currency string in it that I then need to convert that string to a double to perform some operations on it. "$1,100.00" -> 1100.00 This needs to occur all client side. I have no choice but to leave the currency string as a currency string as input but need to cast/convert it to a double to allow some...