javascript

Why doesn't Javascript let me close up my function?

I dunno guys, this is a really weird one, but I might just be making a simple mistake and not even realizing it. I'm sort of a newbie to Javascript, so I'm attempting to write a script that gets content from a PHP script (which returns only a number) and write that data to a div... but Javascript had other ideas. I'm testing on Chrome o...

setTimeout stalls while loop

I set up a slide show (Slideshow()) using setTimeout, and it works fine. I need to limit the slide show to 3 repeats, but when I add a while loop (Count()) it it prints Test 1 and stalls function SlideShow() { setTimeout("document.write('Test 1')", 1500); setTimeout("document.write('Test 2')", 3000); setTimeout("document.write('...

Javascript class defenition

When the myClass function returns a single string "hii", testClass.getDetails() works fine: function myClass(name, age) { this.name = name; this.age = age; return "hii"; } myClass.prototype.getDetails = function() { return "mydetails"; } var testClass = new myClass('aneesh', 27); alert(testClass.getDetails()); But wh...

UL in HTML scrollable on iPhone

The HTML page has two section the first section takes the top half and the second section takes the second half. Each section is a <ul> with 25 <li>s. I use event.preventDefault(); in the body to prevent the HTML page from scrolling. but can I still make those two section scrollable? and display them as described above? ...

How to pass an array of strings from PHP to Javascript using $.ajax() ?

I have a PHP script that retrieves names (strings) from database. I would like to pass this array to Javascript using $.ajax(). I cannot understand how should I encode the array in PHP and then decode it in Javascript. Could someone give an example code for this ? Thanks a lot !! ...

DOM exception thrown when the network cable is removed.

The exception NS_ERROR_DOM_INVALID_EXPRESSION_ERR is being thrown in the web application when the network cable is removed. The web app constantly sends and receives message from the server. Can anyone tell what could be causing this error and how to fix this issue? ...

Using variables to check for error condition in Javascript

Hi all, I have a personal simple jQuery validation script. It works when the submit button is clicked and sets up a variable: $errors = false; Then there are series of if statements that check for textbox values and conditions, and if conditions are not met, variable $errors is set to true. The script works except for one thing. If a...

javascript check if img src is valid?

I have something like: document.getElementById('MyPicture').src = 'attempted.png'; If the client cannot get that resource, I would like to replace it with: document.getElementById('MyPicture').src = 'error.png' I know I can put onError=function() in the image tag, but how can I pass the Id to onError, so that I can have one onError...

What can I do with JSON?

Hi. I want to, in brief, find out about what I can do with JSON; whether it is an alternative for JavaScript or what? ...

Javascript arrays question

Is var myCars=new Array("Saab","Volvo","BMW"); and var myCars=["Saab","Volvo","BMW"]; exactly the same ? ...

How to work with HTML elements underneath a canvas

I have a container of some HTML divs and with some CSS if I hover over them, the background color changes. I want to overlay a canvas on top of the container so that I can draw lines. The problem is that when the canvas is overlaid, the hovering changes of the divs no longer works. Is there a way to overlay a canvas but still have CSS or...

sIFR doesn't apply to children in list

I am unable to remove bullets in nested unordered lists after sIFR has been applied. I experinced this on a website I was creating. I tried to create a basic HTML skeleton and apply the sIFR to easily figure out how to remove child bullets, but it didn't work here either. <ul> <li>Option 1</li> <li>Option 2 <ul id="menu...

Using attr on elements created with javascript

If I create a new DOM element with Javascript document.createElement, is there a way to use jquery function attr() to change the element's attribute? ...

Communicating between 2 flash swf's using ExternalInterface

I been suffering with a problem where I can't get one flash swf to work in unison using one javascript. For example 1.swf does ExternalInterface call to js function test var test = function (var) { $("#2ndFlash").get(0).passTest(var); } As you see what I'm trying to do is when 1.swf calls test with some variable pass it to anoth...

JavaScript visual element selection, deletion

Hello, Many of you already familiar with Firebug Inspect option, which allow to move around in loaded web page and select web page Elements for inspection. Maybe someone know any similar JavaScript which could do the same? I need to allow user to select and remove web page element at runtime. User visit web page, move mouse on element...

How to pass textbox value to another script on link click event.

I have a form like this: one.php <form id='myFormId' name='myFormName'> <input type='text' name='myTextField'> <a href='two.php'>Show Value</a> </form> Question: I want to pass 'myTextField' textbox value to two.php and want to echo it on screen. I can't use submit button and also can't submit the form. Is there any trick ? Tha...

Javascript Opacity Issue

Using absolute positioning, I have placed a div with opacity of 0.5 in front of an image by giving it a higher z-index. Also using absolute positioning, I want to put another smaller div in front of the first div using a higher z-index. This smaller div would show only part of the image (like a window), but have no opacity. Eventually, I...

ASP.NET MVC 2 & Dynamic JavaScript

Hi, I have an unordered list that when an item is clicked it displays several images using the Fancybox JavaScript plugin. I am trying to convert this to ASP.NET MVC 2 and I want to dynamically pass the Image Paths and Title etc. to the JavaScript so that they are not hard coded. HTML <ul> <li><a href="DisplayImages();" title="...

accesing html form array inside javascript

how can i access an array, defined in the form, inside javascript. e.g i have defined an integer array inside the web form like <% using (Html.BeginForm()) { int[] ctid = ViewData["ct"] as int[]; var x = 0; %> now i want to access this array(ctid) inside javascript, how can i do that... plz help ... ...

Replacing a DIV?

I need to replace a div with another div, I have no idea how to do this?? Is there a way to place a div on top of another div and then just make the one transparent? ...