javascript

JavaScript Variable Scope

What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally? ...

JavaScript "For ...in" with Arrays

I've been told not to use "for...in" with Arrays in JavaScript but never received a satisfactory reason as to why not. The question is: Why is using "for ...in" with array iteration such a bad idea? ...

CSS rollover problems with Internet Explorer 7

I wrote some CSS in my HTML code to create rollover buttons. Then i tried to run it with IE 7 and surprise! it doesn't run. In fact it shows both the button and underlying rollover. How can i get around IE's inability to cache background images? Preferably using CSS but javascript 'will' be tried. Sample CSS: #Menu { width: 100...

Implementing UpdatePanel manually

I was reading an article that shows how bad CodePlex uses UpdatePanels and how nice is StackOverflow on this matter when, for example, a user upvotes an answer/question. I wonder if someone can point a tutorial on how to do such action. I know some points: Create a Web Service that gets the action value and ouputs a JSON string Build...

JavaScript Object Literals & Array Literals

What is the difference between Object Literals and Array Literals in JavaScript? I know it has something to do with the length method but i don't fully understand it. ...

JavaScript Array Delete Elements

What is the difference in using the delete array element as opposed to the array.splice method. Why even have the splice method if i can delete elements in the array like i can with objects? for ex: myArray = ['a', 'b', 'c', 'd']; delete myArray[1]; or myArray.splice (1,1); what's the difference? ...

Returning JSON in GWT

I'm still pretty new to JSON and GWT and I'm trying to figure out how to pass JSON data back from a page into my GWT app. I pass the JSON back to a class: public class GetProductTree extends JavaScriptObject { protected GetProductTree() { } public final native String getCustomerName() /*-{ return this.customername; }-*/; } ...

Using jQuery, how can I store the selected values of a select into an array?

Thanks for reading this. I would have thought it would be as simple as using the .split function on the select .val(), but I get a js error. This is the code I am using. I will use .each() to loop through the selected items...but would like to understand what I am doing wrong... If I set opts with a literal..the split works (commented ...

JQuery accordion not hiding sections

Hello Everyone, I want to use the jQuery accordion tool for a form i'm building so I used some sample code from the jquery website but it doesn't work at all! The javascript does nothing at all so you just get the html rendered. I am using version 1.3.1 of jquery with version 1.6rc6 of jquery-ui. <head runat="server"> <script src...

hover() and click() not playing well together

Given the following code,the hover function works correctly, but when clicked, loses the clicked_no_event_box class. Not sure where I'm going wrong... /* On document.ready.. */ $(function(){ $(".no_event_box").hover( function(){$(this).addClass("clicked_no_event_box");}, function(){$(this).removeClass("clicke...

Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)?

I use a datepicker for choosing an appointment day. I already set the date range to be only for the next month. That works fine. I want to exclude Saturdays and Sundays from the available choices. Can this be done? If so, how? ...

How does Google mail achieve rtf in textarea?

I am intended to develop a rich input textarea similar to Google mail. Any ideal or resource to share? Thanks in advance! ...

how to show a 'working' indicator while inserting a big numbers of dom elements

While creating and inserting dom element's, it seems that the fuctions used for the task are returning before the elements show in the page. Before starting to insert the elements i set the display property of a div to 'block' and after inserting the elements i set the property to 'none', the problem is, the indicator is not showing in ...

Javascript comma operator

When combining assignment with comma (something that you shouldn't do, probably), how does javascript determine which value is assigned? Consider these two snippets: function nl(x) { document.write(x + "<br>"); } var i = 0; nl(i+=1, i+=1, i+=1, i+=1); nl(i); And: function nl(x) { document.write(x + "<br>"); } var i = 0; nl((i+=1, i+=...

Why does the "onmouseover" event use "return true" to prevent default behavior?

I have been searching for this for some time, but haven't got any explanation. For "onclick" and other events in javascript, the event handler returning false means "prevent default action". However, there is one exception for "onmouseover". For "onmouseover", returning true means "prevent default action". Why is there such a weird exc...

Structs in Javascript

Previously, when I needed to store a number of related variables, I'd create a class. function Item(id, speaker, country) { this.id = id; this.speaker = spkr; this.country = country; } var myItems = [ new Item(1, 'john', 'au'), new Item(2, 'mary', 'us') ]; But I'm wondering if this is a good practice. Are there any...

Ajax using file upload

Hi friends, i am creating mail page for sending mails. I need to attach some file before sending. How could i do this using AJAX. Initially i need to store those files in server and then i have to send the mail. These actions are done with in a single send button. Please help me. ...

How to do Trim operation to remove space character in a text field in JavaScript?

How to do Trim operation to remove space character in a text field in JavaScript? ...

Flash Player trust file not working with Embedded browser on linux

Hi, I have an application which embeds a browser based on Xulrunner inside it. I have couple of flash swf files I need to load in the browser. The swf files talk with a javascript to change the page title and also to change the URL when I am browsing through the content in the URL. I need the URL change because I need to remember where ...

How do I use rangechange() on the Google Annotated Time Line to only get data for the selected range?

I have a large number of data points that I want to graph using the Google Visualization: Annotated Time Line. I imagine that outputting, say, 100,000 data.setValue points in JS (using PHP similar to the method described here) to build a DataTable will cause performance issues. Instead, I want to output a small number and then increase d...