Saturday, October 26, 2013

DOM select elem length changes if input and select give same name

Below, removing the 't' from the input name, cause button click to change to 'INPUT'


<form name="f1"> <input type="text" id="foo" name="uhuh" value="66" /> <input type="text" name="thesellt" onchange="alert($.inArray(this, document['f1']['thesell'])!=-1);" /> <select name="thesell"><option value="1">one</option> <option value="2">two</option> </select> <input type="text" name="farr" value="33"/> <button onclick="alert(document['f1']['thesell'].length +document['f1']['thesell'][0].tagName );return false;">clikme</button> </form>gt;one