javascript

Manipulating dates in Javascript without the Date object

It appears I can't use the javascript Date object as it inherintly defaults to US dates when you initialise with a datestring. There is no way of passing any culture information to the date object I.e. No matter what the clients locale settings are var d = new Date("08/10/2009") will always create a date object representing the 10th Au...

Remove whitespace and line breaks between HTML elements using jQuery

Using jQuery, I'd like to remove the whitespace and line breaks between HTML tags. var widgetHTML = ' <div id="widget"> <h2>Widget</h2><p>Hi.</p> </div>'; Should be: alert(widgetHTML); // <div id="widget"><h2>Widget</h2><p>Hi.</p></div> I think the pattern I will need is: >[\s]*< Can this be accomplished without...

Explicitly calling the autocomplete function in jquery autocomplete plugin

I have a text field to which I have a jquery autocomplete event attached. However, due to some reasons, I dont want the search results to appear when the user types, but rather when a button is pressed. I know this sounds lame, but I have my reasons. How do I trigger the autosearch results to appear by calling an explicit function? ...

using getElementById to retrieve styless in CSS

Why is the first alert box empty, but the second one says 100px? I'd expect the first box to say 300px.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/html...

Stand-alone animate function (like Jquery)

Hi all, I am currently using JQuery to perform a single task: animation of width on a div. I really hate to be loading in the entire JQuery library for this single task and was wondering if anyone knew how to do a standalone function like: div.animate('56'); Where 56 is the percentage of the width I'd like the div to animate to. If...

Javascript Popup IE Error

I've stepped into a new position and am tasked with cleaning up pre-existing code. I will be posting a Javascript function for building hotel reservations by using a base URL and then carrying over variables to the other site. More clearly, this function allows your to access Site A and search for hotel reservations on Site B. The fun...

Animated gif does not animate on page load in IE

I have a resource intensive ASP.NET page. I have a div element with an image that I set the visibility for before and the after the page loads. This fails in IE. IE stops animating the image. I have tried all possible solutions that were presented in different message boards with no luck. Any help is really appreciated. ...

Automatically refresh and download Asirra images

If you're unfamiliar with Asirra, it's a CAPTCHA technique developed by microsoft that uses the identification of cats and dogs rather than a string of text for human verification. I'd like to use their database of millions of pictures of cats and dogs for some machine learning experiments, and so I'm trying to write a script that will ...

Re-populate complex javascript objects from JSON

Say I have a web form that consists of a input text field, an Add button, and a Submit button. A user can add text to a div by typing some input and clicking Add, which will dynamically (using javascript) append the div with whatever they typed. Also during Add, I'm storing the text in a javascript object. After adding one or more ite...

Javascript scope issues

Hello, I am extending dojo's dojox.data.JsonRestStore and I want to provide my own fixed scheme. this is getUsername won't work because it doesn't refer to the current datastore Take a look at this code: /** * @author user */ dojo.provide("cms.user.UserAuthenticationStore"); dojo.require("dojox.data.JsonRestStore"); dojo.declare("c...

Prevent user from writing more than N characters in a textarea using Prototype event observers

I am aware that it's possible to emulate the maxlength property from input elements on a textarea by using this trick: <textarea rows="5" cols="30" onkeydown="return checkLength(this)"></textarea> <script type="text/javascript"> var maxLength = 30; function checkLength(elem) { if (elem.value.length == maxLength) { return false; ...

prototype serialize returns function instead of serialized string

Hi. I have a script. In it is code. I have a page. In it is some stuff from db. There is an edit button. When pressed, a div pops up and is populated with form fields via ajaxrequest -ing an external php file. the form has a name, and that name is nameEdit. On that form is a button that calls a js function--i.e. submit. in this js func...

Why has innerHTML not been added to the w3c specs?

Is there any particular reason that it isn't in any of the the specs? It seems to be supported in all browsers, (although I'll admit it doesn't work right in all of them...since you have to use libraries like innerXHTML to get it to work right thanks to Internet Explorer. Is innerHTML in danger of disappearing from forthcoming versions...

firefox allowing site in popup blocker causes new tab to open

Ok pretty random situation here and I'm kind of just grasping for an explanation so I hope this makes sense: Our site launches reports in new tabs/windows using the basic 'window.open' javascript function. The reports are one-off things you are just meant to close when finished with them. This works fine in general. We give open 2 para...

Capitalization convention for JavaScript objects

I know this question has no answer, but I'm curious to know what other people think. In a language like Java, it's a convention to begin classes with capital letters, and objects with lowercase letters. But what about JavaScript, where everything is an object? I've seen some people suggest capitalizing only objects that are treated as ...

javascript problem, rss feed display

hi, my code lists items from an rss feed onto an html page. although, the java script is a little finicky. it won't read some xml feeds, usually the feeds containing list items over 25. I just need another set of eyes to take a look at the code and tell me if i'm missing something obvious. .js file---------------------------------------...

some jQuery/javascript help. Add items to optgroup

I have an array called tmp var tmp = ["05", "13", "27"]; if an option value is equal to a value within tmp, I want to add that option to a particular optgroup, else add it to the other optgroup. I keep getting everything added to optgroup #2, except the option with the value "27". What am I doing incorrectly? var groups = $("opt...

jquery call to javascript function inside LIVE Never occurs

I am doing an AJAX call that returns some HTML and jQuery: <div id='selected'>Here is my Selection Text <a id='trashSelected' href=\"javascript:void(0);\">Remove</a> </div> <script> $('#trashSelected').live('click',function delete() { // remove the container $('#selected').remove(); sub...

jqGrid - How to remove the page selection on the pager but keep the buttons?

I want to remove the paging buttons on the grid, but I want to keep the add, edit, refresh, etc buttons on the bottom left. I don't want the pager there because I will be displaying all records in this particular grid implementation. I want to keep what is in GREEN but remove what is in RED: Currently, my solution is to empty out the...

Javascript using Jquery! looping and printing value

Hi, Suppose I have this: <div id="apple" class="fruit"></div> <div id="orange" class="fruit"></div> <div id="grape" class="fruit"></div> <div id="pear" class="fruit"></div> How do I write a javascript function that can loop and print out all the fruit IDs with class "fruit"? Using JQuery. ...