javascript

Browser Neutral Way to add options to a select element in javascript

I just learned something interesting. The add method for the javascript select object in IE 6 takes only one parameter. It throws an error when you pass it two parameters which I believe is the standard, even as documented on the MSDN site. My question is this. What is your best-practice recommendation for programmatically adding option...

JavaScript for HTML Form

I'm a simple soul with simple needs, and I'm trying to configure a form. I detest forms. It needs to have JavaScript to transfer the data, it needs to send an e-mail with the data to an e-mail address, and it needs to redirect visitors to a pdf. CGI has always been confusing to me, and I don't know much JavaScript. I've already done ...

Javascript invalidated after dom manipulation

My page has two components that depend on Javascript. On the left hand side, there is a attribute base navigation (abn). And the right hand side is the Result of the abn. There is an event handler for abn and an event handler for the result (both are on clicks) Whenever the user clicks on the abn, I do an ajax call which returns a json ...

URL decoding

I want to decode string which is encoded using java.net.URLEncoder.encode() function. i tried using unescape() function in java script. but problem occure for blank space because java.net.URLEncoder.encode() converts blank space to '+' and unescape() function wont convert '+' to blank space. ...

Identifying list item index - which is a better approach?

I need to pick up list items from an list, and then perform operations like adding event handlers on them. I can think of two ways of doing this. HTML: <ul id="list"> <li id="listItem-0"> first item </li> <li id="listItem-1"> second item </li> <li id="listItem-2"> third item </li> </ul> Using the IDs- ...

How do you manage your DojoX code?

How are you managing your usage of DojoX code or widgets in a production application? The Dojo Toolkit is comprised of Core, Dijit, and DojoX. As an incubator for new ideas to extend the toolkit, DojoX code and widgets are functional with varying degrees of instability. DojoX Code like QueryReadStore (for fetching batches of data from...

How to Stop Click Event From Executing in Javascript Function?

I am trying to assign the onclick event to an anchor tag that already exists when I click on another element. However, everything I've tried seems to result in the firing of the event immediately after assignment. We're using Prototype and Scriptaculous. This is the function: <script type="text/javascript"> function loadData(step, d...

Change an element's onfocus handler with Javascript?

Hello, I have a form that has default values describing what should go into the field (replacing a label). When the user focuses a field this function is called: function clear_input(element) { element.value = ""; element.onfocus = null; } The onfocus is set to null so that if the user puts something in the field and decides ...

How can I find the source of rogue Ajax requests on IE?

I've rewritten my family web site using Javascript (JQuery) making ajax calls to php on the back end. It's your standard "bunch of image thumbnails and one main image, and when you click on a thumbnail image the main image changes" kind of thing. Everything is working as expected when using Firefox, but on IE, when I click on a thumbnail...

Javascript; Sending user to another page

I am trying to send a user to another page using a Javascript Function: INPUT TYPE = Button NAME = "confirm" VALUE = "nextpage" onClick = message()> SCRIPT language = JavaScript> function message() { ConfirmStatus = confirm("Install a Virus?") if (ConfirmStatus == true) { //Send user to another page } } /SCRI...

PHP version of confirm() of JavaScript

Is there a PHP version of JavaScript's confirm() function? If not, what are my other options or how do I make something similar to the confirm()? ...

Display confirmation popup with JavaScript upon clicking on a link

How do I make one of those hyperlinks where when you click it, it will display a popup asking "are you sure?" <INPUT TYPE="Button" NAME="confirm" VALUE="???" onClick="message()"> I already have a message() function working. I just need to know what the input type for a hyperlink would be. ...

How to hide a caret in IE? (JavaScript)

While displaying a pop-up window above a wysiwyg editor, the caret (cursor in text area) is still visible under the pop-up window. Any ideas? ...

Making a drop-down list using scriptaculous and prototype's BlindDown or SlideDown effect

I'm trying to make a javascript dropdown list using scriptaculous and prototype. I know this can be done using CSS :hover pseudo-selectors, but I would like to add some additional flair to it. The problem is that while I can kind of get the dropdown/up effect working, it seems very flaky. Is there a simple way to do this, or should I sti...

jQuery with elements generated dynamically

I've been working with jQuery for a pair of weeks and I've noticed it works fine with objects that are in the original HTML document, but when I generate a new element using jQuery the library doesn't get any of its events. Let's say I try to run something like this: $('.whatever').click(function() { alert("ALERT!"); }); If the HTM...

How can I populate another dropdown with the onChange event of the first dropdown?

Hi, with jquery, or with simple just javascript, I want to populate a 2nd dropdown from the choice of the first dropdown. The value of the first dropdown is the condition to get rows for the second dropdown. How does the onChange event look like? ...

How do I retreive an HTML element's actual width and height?

Suppose that I have a <div> that I wish to center in the browser's display (viewport). To do so, I need to calculate the width and height of the <div> element. What should I use for maximum browser compatibility? Looking for a solution that works on IE6+, FF2+, Opera and Webkit-based browsers (Safari 3+, Google Chrome). ...

JavaScript implementation of Gzip

I'm writing a Web application that needs to store JSON data in a small, fixed-size server-side cache via AJAX (think: Opensocial quotas). I do not have control over the server. I need to reduce the size of the stored data to stay within a server-side quota, and was hoping to be able to gzip the stringified JSON in the browser before sen...

How do I get the mouse button pressed from a command event in XUL?

It seems that the XUL command and click events are somewhat different. Although my function does get called when using the command event, the event object does not contain the button property. My question is: how do I detect what mouse button that was pressed without using the click event? The simplest code that can demonstrate my pro...

Creating a Drop Down Menu That Changes Page Content Using Show/Hide Layers and Z-Index

I am trying to create a sidebar for a site that will allow a user to select an item from a drop down menu and show an RSS Feed. The feed will change depending on which item is selected from the list. I am not sure how to acomplish this, but my first thought was to use z-index and show/hide layers. I have one layer and the menu set up, bu...