getelementbyid

Pushing mouse click location to an array in Javascript

Hey guys, I'm trying to push the coordinates of a mouse click on a particular element to the end of an array. This is what I have: IN THE HEAD: var seatsArray = []; IN THE BODY: var coordinates = document.getElementById("image"); coordinates.onclick = function(event) { seatsArray.push(offsetX, offsetY); } document.write("Seats ar...

Can't find flowed text element by ID in SVG

I've been playing with animation in an SVG: http://imgh.us/renamon-animtest.svg (links to script "anim.js") In the window.onload event, I have: function init(evt) { if(window.svgDocument == null) { if(evt.target && evt.target.ownerDocument) svgDocument = evt.target.ownerDocument; else if(evt.original...

Ajax loading images in XML - loading image and fade?

I am loading in an XML document with multiple photos in it, via ajax. The process my function goes through is this: Open a UL Open a LI Open an img tag set the src to = the url in the xml document (see below) close img tag close LI open a LI open an img tag set the src to = the url in the xml document (see below) close img tag close LI ...

Know the length of an input in Javascript

Hello, how to know the length of an input in Javascript alert("Size: "+document.getElementById('champ').length) not work undefined ...

Why does facebook have random element IDs ?

I have noticed that facebook has random element IDs for every element - including elements that have no unique element id. <div id="__w2_YvdN1r2_loading">blah</div> Any ideas why they do this on every element & how they do this? ...

If I use "getElementById" to alter a CSS style of a single object, how do I alter all elements that inherit the style?

All the examples I've seen use "getElementById" to get the single element, and then change that style for that singular element. I'm in the situation where I need to modify all the matching elements on the page with a style. I need to change the font size, height, and width. How do I do this, and is jQuery required or optional? The r...

Javascript For Loop On Array of Input fields issue with document.getElementById

Hello, I have an serverside script making an amount of text fields for me. When I want a user to fill them up, and submit data. I know how many fields there are, as the server also sends a count. I am then trying to join them into a long string with a spacer between. But I am having trouble getting the value of the array. Better exp...

Javascript working on Firefox but not in Chrome and IE6

I have javascript that working fine in Firefox 3.x.x, but it does not work in IE*, Chrome, Safari. Simple alert work before calling function. Here is the code function showDiv(div){ //alert(div); document.getElementById(div).style.visibility='visible'; document.getElementById(div).style.height='auto'; document.getElementById(div).s...

javascript: getElementById problem in IE

I am trying to attach a click event to a check box using JavaScript. Shown below is the HTML and JS. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <input type="hidden" nam...

document.getElementById("").src - file path is changing, but image is not

I am simply trying to change the source of an image using JavaScript. Watching in Firebug shows me that when my function is called, the image paths are changing, however, the image itself is not switching. Has this ever occurred to anyone? ...

JQTouch glitch on the iPad

I have a simple JavaScript function which replaces an image's source. document.getElementById("star1_"+i).src ="full_star.png"; i being an id attached to the name to differentiate different stars. It works fine in Safari, but once I add the site to home screen, this action stops working and the image source does not get replaced. Is t...

javascript hide/show example - close divs

In this javascript hide/show example, how can I close all other divs when a div is selected? <script TYPE="text/JavaScript"> function show_hide(id, show) { if (el = document.getElementById(id)) { if (null==show) show = el.style.display=='none'; el.style.display = (show ? '' : 'none'); } } ...

How can I get a <p> element in a <td>?

I want to get a "p" element which is inside a "td". How can I get it? My code is: <td id="mytd"> <p> aaaa </p> <p> bbbbb </p> <p id="myp"> cccc </p> </td> I can get the td using. document.getElementById("mytd"), but I don't know how to get the p with id="myp". Thanks is advance ...

Can I change the ID of an HTML element using Javascript?

I have javascript variable obj which represents an element in the DOM and I wish to change its ID. I have attempted to do this by the following, which also illustrates that it does not work! obj.id = "newID"; alert(obj.id); // this gives me newID as required var element = document.getElementById("newID"); if (element != null) { alert...

Why is document.getElementById() returning a null value when I know the ID exists?

I'm working on some custom Javascript for a CMS template at work. I want to be able to make a certain <li> element on the page receive the class of "current" for that page only. So in the global page head I have something like this: <script type="text/javascript"> function makeCurrent(id) { var current = document.getElementByI...

javascript textbox: enter text and it appears instantly in another textbox

Javascripters, a 'puzzle': Using a simple HTML form, make two textboxes. Whatever text you type (say, some random string of characters like asdfasdf ) into textbox #1 is IMMEDIATELY displayed, on the fly, without pressing any button or changing focus, into textbox #2. Can it be done using getElementByID? ...

Why is my JavaScript alert message displayed before an image is updated using document.getElementByID?

In my JavaScript code I am first calling a function to update an image: document.getElementByID("i1").src = newImage; then a few statements later the alert() function is called to display a message: alert("image updated!"); However, when I run this code, what actually happens is that the alert box is popped up before the image is u...