javascript

Replacing radio buttons with different images

I need to create a group of 2 radio buttons (options: male / female) that display images instead of the actual buttons. The images should change upon selection. So there should be 4 images: male (on), male (off), female (on), female (off). I'm using jQuery throughout the site, and I would like to use jQuery for this, too, if possible. ...

Script elements written with document.write in a window opened with window.open are not executed in IE8 on Windows 7

I'm running into an issue that seems to only appear on Windows 7. It seemed to work fine in IE8 on a different version of Windows. Basically, I'm creating a new window with window.open(), then using document.write() to write the contents of that new window, which contains script includes. In IE, these scripts are not being executed pr...

Parsing input to see whether it's an address, zip code, city or state?

I have a job board where a user submits his location, via Google-Maps API, which plots the job on a map. The problem is, because it is a location based job board, I want to make the most broad input allowable a ZIP code (so users can either enter a ZIP code or address). Is there anyway to either parse the input to determine whether it'...

How do I detect when an input is changed?

Via JavaScript, PHP, or HTML. I want to do this to check if a username is allowed (on our side). Sorry for not elaborating too much. If the username is too short, a message will appear next to it (I will do this part) saying that it is too short, but for this to be done automatically I would need for it to be detected. <script type="te...

[jQuery] How to wait a fadeout effect and then remove the element?

I have a tr which will be removed when clicked in delete button, but before doing .remove() or empty() I'd like to wait for some fadeOut() effect. $(this).closest('tr').fadeOut(); setTimeout("$(this).closest('tr').remove()",1000); is not working, it only fades out. ...

Drag (move) a polygon using Google Maps v3

The Google Maps API for a Polygon does not offer a drag method. What would be an efficient way of implementing such a feature (i.e., sufficiently optimised so that it would not kill a four year old laptop)? Thank you! ...

Options for Javascript Client Library for a Server Side API

I would like to write a Javascript library to wrap an API I plan on using in my application. Now because of XSS restrictions I cannot simply have my script call out to the server hosting the API. What are the options to get around this? My initial research has turned up: proxy: have the client library make calls back to my webapp's ...

Hiding Panels and Divs on ASP.NET is making me crazy.

Searching on google, i deffinitly can't find a non-javascript way to show and hide my panel/updatepanel. I do have panels and updatepanels, I want to show/hide them on the fly, after a button click, preferably without javascript, or if so, with jQuery. All the examples I found consumes a lot of code and honestly I don't want to crap ou...

On client, how do I download an image, then send as POST request to third party server?

We're using GWT and want to download an image to the client, then send this image to another server using a POST request... A JavaScript/AJAX solution would be helpful too. Is this plausible? Can a web app access cached images from the client's browser? We're rookies, if this is futile please let us know. Thanks! UPDATE: We abandoned...

the future of Javascript

how do you see the future of javascript as a (main) web browser scripting language? there are browser-dependent variations of javascript support, javascript itself has some flaws. this could possible lead to incorporation of some dominant js framework into the leading open-source browsers, or promotion of a different (or completely new)...

How can I add a "Vary: Accept-Encoding" header to a file on Amazon S3

In Amazon's S3 Management Console, I'm trying to add metadata, with the key being "Vary" and the value being "Accept-Encoding". This seems to work, I hit save. But when I hit refresh it disappears, as if Amazon rejected the tag. The file in question is a gzip compressed javascript file. My other headers are working and added properly ...

Do you recommend against javascript based LESS?

After I watched this NetTUTs video, I'm very interested in trying out the LESS.js method shown. Other than the obvious, "What if the user doesn't have javascript enabled?", or "There's going to be a small performance hit"... is there a reason this cannot be used in production? LESS essentially looks like what CSS should be... ...

JavaScript link click counter

i need a script to count link clicks on my website and count report to a flatfile/excel. ...

Chrome, javascript Date and toLocaleString()

Why doesn't Chrome specify AM or PM when displaying a date by using date.toLocaleString() ? The string I get is Fri Jun 25 2010 11:21:09 GMT+1000. While IE returns almost the same string but with AM after the time. Is there any method on the Date object I can call to check whether it's AM or PM and, more importantly, check whether user'...

What is the purpose of an anonymous JavaScript function wrapped in parentheses?

Possible Duplicate: JavaScript: Why the anonymous function wrapper? I read the code of some JavaScript libraries, and found in some js files there are such statements: ;(function(){ })(); I've got a few questions : What the code does? Why the code is designed in such way? How to invoke functions defined in the code? ...

Click event handler inadvertently bubbles, even after calling jQuery's stopPropagation()

Hi, I'm trying to have different delegate click handlers for different elements within "li" elements in a list. Example: <ul id='myList'> <li> <p>First item.</p> <button>button1</button> <button>button2</button> </li> <li> <p>Second item.</p> <button>button1</button> <button>button2</button> </li> </ul> ...

How to escape regular expression special characters using javascript?

Hi to all, I need to escape the regular expression special characters using java script.How can i achieve this?Any help should be appreciated. ...

How to refer to currently selected element in jQuery?

I'm trying to make a script that would insert img element after each link to a certain site with source equal to value of href attribute of given link. This is what I came up with: $("a[href*=site.com/img/]").after("<img src="+$(this).attr("href")+">"); Problem is, $(this) doesn't work (attr() returns undefined). Why is it? How to ref...

What do you do with unused code in your legacy applications?

On huge legacy applications it is fairly common to see change in business rules leading to unused code. Is the deleting the best way? or Are there any standards of marking the unused code? SCM does help to get the old code back if needed. Also this is specific to .NET code bases. ...

Automatic newline in textarea

Using jQuery, how can I make a textarea that automatically adds a new line when inserting text when the cursor is near the end. The width of the textarea is dynamically done via CSS (e.g., #myTextArea { width: 80%; }) so I can't do anything like counting the characters in each line. I don't need a non-JS solution since the content of t...