You are here: Re: HTML Twins « HTML « IT news, forums, messages
Re: HTML Twins

Posted by Matt Kruse on 11/29/05 16:40

Sathyaish wrote:
> (1) Can two HTML controls have the same name? It looks like the
> obvious answer is NO.

Yes they can. In fact, it's required for radio button groups!

> (2) What if? What if the developer has given two HTML controls the
> same name, i.e has created the same button more than once with
> exactly the same name and all other attributes? What happens then?

Instead of document.forms['formName'].elements['elementName'] referring to a
single input, it will now be a reference to a collection of the inputs with
form name 'elementName'. In fact, the elements with the same name don't even
need to be of the same type!

> For Each HTML Control In The Form On The Document
> If The HTML Control Has a Value Of Edit Then
> Disable It, or do something with it like show me its name and
> value
> End If
> Next HTML Control

var inputs = document.forms['formName'].elements;
for (var i=0; i<inputs.length; i++) {
if (inputs[i].value && inputs[i].value=='Edit') {
inputs[i].dislabed = true;
}
}

Although, wouldn't you want to check for the NAME attribute rather than
VALUE?

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация