javascript

jQuery remove SELECT options based on another SELECT selected on change and on load

I'm using the following jQuery code to remove options from a select and it is working well. But instead of it only executing when the theOption2 select is changed I would also like it to work when the page is loaded depending on the selected item that is selected. I tried using the a copy of the script and changing the .change to .load a...

Loop through array in JavaScript

In Java you can use a for() loop to go through objects in an array like so: String[] myStringArray = {"Hello","World"}; for(String s : myStringArray) { //Do something } can you do the same in JavaScript? ...

Problem using ScriptManager.RegisterStartUpScript in user control - Script Error "function is not defined"

I have a aspx page which contains a User Control uc1 ans within uc1, there is another user control uc2. Now I need to call a javascript function in the uc2's page load. (I understand that the Pages are not properly designed, but I am sorry as this is an old application, I am not supposed to make any changes in the design) I am doing thi...

Dojo extending dojo.dnd.Source, move not happening. Ideas?

NOTICE: THIS IS SOLVED, I WILL PUBLISH THE SOLUTION HERE ASAP. Hey all, Ok... I have a simple dojo page with the bare essentials. Three UL's with some LI's in them. The idea si to allow drag-n-drop among them but if any UL goes empty due to the last item being dragged out, I will put up a message to the user to gie them some instructio...

Object inside of array -- works in one scope but not in another?

Ok I've been learning some of the more advanced aspects of Javascript and now trying to use this I'm stuck. Here is my code: function Data(){} function init(state){ var item; item=new Data(); item.fieldrid=17; item.description='foo'; state.push(item); }; function findInState(state,fieldrid) { for (var item in state) {...

Flash Player scripting + IE8

I've developed a small control bar for a Flash viewer generated by a third-party software. It has a First, Prev, Next & Last button, and a Zoom command. While Zoom works fine in all browsers, the navigation buttons seem to fail at Internet Explorer 8. I use at least two functions. This one locates the Flash object I want to manipulate:...

How do I make a "input type text" go invisible with JavaScript?

<input type="text" value="Text box"/> <input type="button" onclick="toggle();"/> How do I make the text box disappear and reappear with JavaScript? ...

Alias method chain in JavaScript?

In JavaScript, how could you create a new function with the same name as an existing function, while also preserving the original function so it could be called from within the new one? ...

How do I use HTML inside a JavaScript code?

I want to change the page, I'm not sure if it is possible with JavaScript, so I tried with HTML, and it failed. if (text=="home") {'<meta http-equiv="REFRESH" content="1;url=index.php">'; return;} Any ideas on how to do this? ...

onMouseMove get mouse position

In javascript, within the javascript event hander for onMouseMove how do I get the mouse position in x, y corrdinates relative to the top of the page? ...

regex in textfield

dear all..i have this code: <script> var str="KD-R435MUN2D"; var matches=str.match(/(EE|[EJU]).*(D)/i); if (matches) { var firstletter = matches [1]; var secondletter = matches [2]; var thirdletter = matches [3]; alert(firstletter + secondletter + thirdletter); }else{ alert (":("); } </script> i want it can contro...

clear javascript console in Google Chrome

Hi, I was wondering if I could clear up the console with some command.. console.log(), can print... is there a command to clear up console?.. I've tried to console.log(console); and got this functions below... assert: function assert() { [native code] } constructor: function Console() { [native code] } count: function count() { [nati...

JavaScript OOP problem

I create windows like this: var obj = document.createElement('div'); obj.className = 'window'; obj.style.width = 300 + 'px'; obj.style.height = 200 + 'px'; obj.style.left = 30 + 'px'; obj.style.top = 200 + 'px'; //and so on and what I need is to attach some data to each window. The data will be grabbed via Ajax and displayed in...

How to improve performance of coverflow in javascript

Hi all, I am trying to add a coverflow in an application for set top box. I have downloaded some cover flow controls in javascript which are freely available in net and all looks good when there are limited number of images. But if i put some 500 odd images, all hanged up. Do any one knows a better logic to avoid this kind of problem. I...

Is it possible to see a difference between mouse click and obj.click()?

Hello, Lets say there is a form with a submit button. I found out that using javascript i can call the click() method for input elements in Firefox which would simulate the mouse click on that element. But then, i got this question, can you detect if button was clicked with real computer mouse, or .click() method? Thank you ...

Why does isNaN(123.) return false?

Hi, Why does the Javascript function call isNaN(123.) return false? (notice the dot (.) after 123). Is this a universally acceptable number or will it cause errors downstream? I'm validating whether a value is a valid decimal using isNaN along with split. Are there cross-browser issues with isNaN? Should I use a bespoke implementation?...

how to using jquery get select element has MULTIPLE mode and reverse

Hi everyone! I have a stack with my work today. My stack here: I have a select html element and it has MULTIPLE mode: <select class="test" MULTIPLE></select> (MULTIPLE mode also type as : multiple="multiple" i inclue here) <select class="test" multiple='multiple'></select> now i only want select this element in many normal select ...

Displaying Google Calendar event data on FullCalendar

I am using Google Calendar as a storage engine for a calendar system I am building, however, I am using a single Google user account with multiple calendars, i.e. each user on my system has their own calendar within the one user account. I'm able to create a calendar per user just fine, but I would like to have FullCalendar retrieve the...

Load javascript via Firebug console

How can I load a javascript file via Firebug console ? This would be useful in development, so I don't have to modify the html code to load the script. ...

Weird syntax for extending jQuery

I recently saw this code on another post ( http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area ) new function($) { $.fn.setCursorPosition = function(pos) { // function body omitted, not relevant to question } } (jQuery); After too long trying to understand what it was doing I finally figur...