getelementsbyname

javascript loop only applying to every other element

i have the following javascript below after i finish an ajax query all of my images have name="pic" <script type="text/javascript"> function done() { var e = document.getElementsByName("pic"); alert(e.length); for (var i = 0; i < e.length; i++) { cvi_instant.add(e[i], { shadow: 75, shade: 10 }); } } m...

What is the most effective way to create a reference to this HTML element using plain JavaScript?

If I have the following HTML: <div id="container"> <iframe></iframe> </div> What is the most effective way (mainly in terms of performance) to create a reference to the <iframe> DOM element? I'm using something like the following: var element = document.getElementById('container').getElementsByTagName('iframe')[0]; IIRC, though, ...

local copy of document.getElementsByTagName

Why doesn't the following code work? var f = document.getElementsByTagName; var x = f('div'); I get "TypeError: Illegal invocation" in Chrome, "TypeError: Type error" in Safari. I don't get an error in Firefox, but it doesn't work. I haven't bothered testing in IE or Opera yet. ...

jQuery and JSON: getting an element by name

I have the following JSON: var json = { "system" : { "world" : { "actions" : { "hello" : { "src" : "hello world/hello world.js", "command" : "helloWorld" } } } } } I have the following javasc...

Best Practice: Accessing radio button group

Looking for the best, standards compliant, cross browser compatible, forwards compatible way to access a group of radio buttons in the DOM (this is closely related to my other most recent post...), without the use of any external libraries. <input type="radio" value="1" name="myRadios" />One<br /> <input type="radio" value="2" name="myR...

Why is my Javascript validation not working?

<script type='text/javascript'> function formValidator(){ // Make quick references to our fields var username = document.getElementByName('username'); var password = document.getElementByName('password'); var email = document.getElementByName('email'); // Check each input in the order that it appears in the form! if(isAlphanumeric(u...

Javascript: Show/Hide multiple elements by name

I need to show/hide multiple elements with the same name when another element is clicked, like <span name="showhide" value="one" id="button">Click to Hide One</span> <span name="showhide" value="two" id="button">Click to Hide Two</span> <span name="showhide" value="shoe" id="button">Click to Hide shoe</span> would hide the elements with ...