|
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]
|