javascript

Javascript Upload to self

How can i upload a file and get its contents in javascript. For example, i want to upload an mp3 and play it in the html5 audio tag without having it on the server. Is this possible? ...

JavaScript replace()

I'm trying to use the replace function in JavaScript and have a question. strNewDdlVolCannRegion = strNewDdlVolCannRegion.replace(/_existing_0/gi, "_existing_" + "newCounter"); That works. But I need to have the "0" be a variable. I've tried: _ + myVariable +/gi and also tried _ + 'myVariable' + /gi Could someone lend a hand ...

Use of "setTimeout()" in my jQuery Expression

I'm trying to add the JavaScript function setTimeout() to my jQuery expression. Without the setTimeout() my function loads a partial view with updated information when I enter text into my textbox. But, it loads the information with every keystroke. My logic is that if I can put in a timer then when the user stops typing, a second lat...

Javascript access TR from TD

Hello. I have a table row, and within that, I have a td (whatever it stands for). I want, without an ID or a name, to be change the class attribute of the TR my TD is in. Like that: <tr> <td onclick="[TR].setAttribute('class', 'newName')">My TD</td> </tr> How do I do it? ...

What is the JavaScript variable scope in a switch / case statment?

While creating JavaScript with ASP.NET MVC I noticed several scope warnings and realized that I am missing something with understanding the variable scope inside the switch / case statement. Warning: 'i' is already defined referring to case b and case c My code looks similar to this: switch(element) { case 'a': for(var i=0; i < c...

javascript "associative" array access

Hello I have a simple simulated aarray with two elements: bowl["fruit"]="apple"; bowl["nuts"]="brazilian"; I can access the value with an event like this: onclick="testButton00_('fruit')">with `testButton00_` function testButton00_(key){ var t = bowl[key]; alert("testButton00_: value = "+t); } However whenever I try to acc...

JavaScript - Building JSON object

Hello, I'm trying to understand how to build a JSON object in JavaScript. This JSON object will get passed to a JQuery ajax call. Currently, I'm hard-coding my JSON and making my JQuery call as shown here: $.ajax({ url: "/services/myService.svc/PostComment", type: "POST", contentType: "application/json; charset=utf-8", data: '{...

A bug in graph while using google visualization API on IE

Hi, i'm using google visulization API to build a line chart grapgh. it works fine on FF and Chrome but i'm having problems on IE7: the problem is that the scailing of the x-axis (string) and y-axis (integer) is all wrong. both axis have the same values for some reason, but naturally those valuse are wrong. my code is the following one: ...

Refresh iFrame (Cache Issue)

We are getting a weird issue on which we are not sure what exactly cause it. Let me elaborate the issue. Suppose, we have two different html pages a.html and b.html. And a little script written in index.html: <html> <head> <script> function reloadFrame(iframe, src) { iframe.src = src; } </script> </head> <body> <form> <iframe id="...

How to I access a page level (local) javascript variable in a greasemonkey script?

I just want my GM script to do a window.alert(foo) where foo is equal to a local javascript variable within the page. Ideas? ...

Why does Firefox re-request unmodified scripts?

I'm testing a PHP function that generates tags for scripts, images and stylesheets, based on just the filename and internal variables that tell it things like 'image files live in the /images directory`'. It appends timestamps to bust the browser cache, spits out image dimensions as needed, etc. (You can read about it and see the code he...

Javascript event simulation library

Do you know a JS library for dom events simulation? I know that this operation can be done but i can't find any library to do it. UPDATE: I try to explain better my question. Javascript can simulate events like the user click, i'm looking for a library that helps me with this operation. ...

JQuery: Toggle submit button according to if terms are agreed with or not

I have a checkbox with id terms and a submit button in my form with class registration. I would like the submit button to be disabled initially, and then to be toggled on and off whenever the user toggle on and off the terms checkbox. I would also like to have a confirmation dialog pop up when the submit button is clicked and that if it ...

how can i put an image into select?

i have this script <select> <option value="1">one<img src="star.gif" height="15" width="15"></img> </option> </select> but it doesn't work. how can i put an image into select? thanks update: so it's impossible?:(maybe via javascript?... ...

creating a data grid in javascript

Hi, I want to know if there is an API to create a datagrid like here: http://socghop.appspot.com/gsoc/program/accepted_orgs/google/gsoc2010 ...

Js variable to json

There has to be a better way of writing the js in my function.... I need to end up with bare json that looks like this [1095365, 1125504]. Setup of code example; var article = {"Id":0,"dirtyFlags":null,"textAreas":null,"metaData":null,"relatedCIs":[{"Id":1095365,"Type":4},{"Id":1125504,"Type":4}],"clients":[{"Id":992754}]}; myFunction...

Setting a session variable in Global.asax causes AJAX errors

I'm getting a very peculiar problem with my asp.net application, it took me an age to track down but I still don't know what is causing this behaviour. If I set a session variable in the Application_PreRequestHandlerExecute event, then my external JavaScript files are ignored, and therfore causing a raft of errors. I have simplified the...

ASP.NET MVC Ajax: Error with Ajax.Actionlink ('b.apply' is not a function in MicrosoftAjax.js)

Hello, I made some changes to my ajax test website and now my Ajax.ActionLinks don't work anymore! The ActionLinks in question are made like this: <%=Ajax.ActionLink("Language Select", "LanguageScreen", "Home", from("LanguageScreen", "Functions"), meep("LanguageScreen", "Functions"))%>` The "from" and "meep" functions are only one li...

swfobject 2.2 showExpressInstall -> How do you specify your desired version of flash?

With swfobject 2.2, how do you specify the desired version of flash you require? I need flash 10, but swfobject won't perform an upgrade install with the provided expressInstall.swf in the swfobject 2.2 distributable. How do I get an upgrade install to occur for flash 10? ...

Run javascript function after Server-Side validation is complete.

Ok, I've got a lightbox with a small form (2 fields) in it, inside an UpdatePanel, and I want to close this lightbox (must be done via javascript) when the 'Save' button is pressed. However, there is a need to have a server-side CustomValidator on the page, and I only want to close the lightbox if this returns as valid. Does anyone kno...