javascript

How to preserve text selection when opening a jQuery dialog

Using jQuery's dialog I came across the following quirk (tested in FF3): User selects text In code, open up a jQuery dialog BUG: the text gets unselected (text could be in a textarea or just an HTML on the page) So, to me it seems like a funny (and annoying) bug or a quirk, but maybe there's a good explanation for that. And what int...

How can I refactor this jQuery code?

The code below is for a simple newsletter signup widget. I'm sure there's a way to make it more concise, any ideas? var email_form = $('.widget_subscribe form'); var email_submit = $('.widget_subscribe .submit'); var email_link = $('.widget_subscribe .email'); // Hide the email entry form when the page loads email_form.hide(); // Sh...

How to update value of a radio using Jquery

I have this HTML code for radios: <input type='radio' name='a_27' value='Yes' id='a_27_0' /> <input type='radio' name='a_27' value='No' id='a_27_1' /> I'm trying to set the selected value of the radio using this code: var field="a_" + this.id; $('[name="' + field + '"]').val(this.value); console.log("name is " + field + ", val is " ...

strange quote behaviour in generated html

I am using the following code snippet to generate a html form for use in a popup window: $uploadhtml = "<form action='up.php' method='post' enctype='multipart/form-data'> <label for='file'>Filename:</label> <input type='file' name='file' id='file'/> <br /> <input type='hidden' name='pk' value='".$pk."'> <input type='hidden' name='usern...

CalendarExtender Change date with Javascript

I have a CalendarExtender control on my page and sometimes have to change the date to the next occuring Sunday. I'm currently using the OnClientDateSelectionChanged property of the control to call a function that will add some days to the date until its Sunday. The problem I'm having is that if I select a Tuesday in my calendar, the tex...

Detect Plugins in Internet Explorer without Instantiating the Object

Normally when you use VBScript or JavaScript to CreateObject to detect a plug-in, the user gets the somewhat "jarring" security exception. What are some good ways to detect IE browser plugins without actually instantiating the object? ...

Is there a standard resource for the "default action" of HTML elements?

I'm wondering if there is a defined standard for what the default action is of various HTML elements. I've looked at the W3C's HTML specification and while they are very precise with what attributes can be used with elements (and also some behavioural stuff such as exactly what gets included with form submission) there's nothing about t...

How to remove all Click event handlers in Jquery

I'm having a problem. Basically, when a user clicks an 'Edit' link on a page, the following Jquery code runs: $("#saveBtn").click( function() { saveQuestion(id); } ); By doing this, the onClick event of the save button calls the saveQuestion() method and p...

function for converting kilograms to pounds and ounces

I'd like to convert kilos into pounds and ounces e.g. if a user enters 10 kg then the function should return 22 lb and 0.73 oz Any ideas? ...

Getting coordinates of an image map with a mouse click

I have an html image map and I want to get the coordinates when a user clicks on the map. Is there a way to retrieve the map coordinates with a mouse click on the map? ...

Headaches with radios in Jquery

I have 2 radios: <input id="a_15_0" type="radio" value="abc" name="a_15"/> <input id="a_15_1" type="radio" value="xyz" name="a_15"/> Both are unselected. I have only the name of the radio, i.e a_15, but not the IDs. 1) How can I get the value of the selected option of this radio? E.g if the user clicked 'xyz', how can I get it? Right...

How to parse a variable in Javascript

I'm trying to use this code: var field="myField"; vals[x]=document.myForm.field.value; In the html code I have <form name="myForm"> <input type='radio' name='myField' value='123' /> 123 <input type='radio' name='myField' value='xyz' /> xyz </form> But this gives me the error: document.myForm.field is undefined How can I get ...

Why does isNaN(" ") equal false

Hi, all. I have a quick question (I hope!). In JS, why does isNaN(" ") evaluate to false, but isNaN(" x") evaluate to true? I'm performing numerical operations on a text input field, and am checking if the field is null, "", or NaN. When someone types a handful of spaces into the field, my validation fails on all three, and I'm co...

Problem adding image overlay (jQuery)

What I want to do is find all images with a particular class name, and place an overlay image over them. My script thus far in jQuery 1.2.6: jQuery.noConflict(); jQuery(document).ready( function($) { var module = $(".module-contactus div div div"); module.find("img.let").each( function() { var iWidth = $(this).width(); var i...

Applying css with javascript overrides hover link style?

I have some JavaScript which is changing an image correctly but once it has been called, my a:hover CSS code no longer works. Looking with firebug the following JavaScript creates this css rule: element.style { background-image:url(/content/images/side_partnershipsOver.png); } document.getElementById('partnerships').style.backgroundIm...

How to select all textareas and textboxes using jQuery?

How can I select all textboxes and textareas, e.g: <input type='text' /> and <textarea></textarea> on a page and have the property style.width="90%"; applied to them? ...

How can I pass a variable to a JSP class using the URL?

I'm trying to modify someone's written JavaScript code to pass a URL variable (called manufacturer) into a Java class. The interesting thing is the file is an HTML file with JavaScript. Because I'm new to JSP, I'm not even sure if this can be done but here is the HTML/JavaScript code: <html> <head> <script type="text/javascript"> var...

Draw radius around a point in Google map

I'm using the Google Maps API and have added markers. Now I want to add a 10 mile radius around each marker, meaning a circle that behaves appropriately while zooming. I have no idea how to do that and it seems it's not something common. I found one example that looks good, and you can have a look at Google Latitude, too. There they use...

How can I Enable\Disable all subcontrols of a table?

Hi, I have a checkBox, which when it's checked i want to enable a table and its subcontrols and when it's disabled I want to do the opposite. I have already understand that I have to iterate all subControls of the table, and my question is if there is any nice and generic way of doing it. Thanks in advance, oz. ...

TinyMCE inside hidden div are not displayed as enabled when we put the div visible

I am having an issue with tinyMCE (WYSIWYG editor). I am actually adding the textarea inside a HTML element like a DIV which is currently having the style attribute "display:none". When I am changing the DIV display style to visible the tinyMCE editor is shown as disabled. Important Note: The setting which is causing the issue is the ...