javascript - Two forms on one page with same input fields -
so have 2 identical forms on page cannot give different names, because tied back-end.
i have few input fiends same id's on diferent forms, checked if empty document.getelementbyid('id').value;
strange thing is, half of input fields checked on 1 of forms , other half checked other form (this when user entering values in 1 of forms), despite them using 2 different javascript functions. 1 input field gets closest id automatically, others goes way other form.
my question how can value of elements checked closest submit button (or other element near 1 of forms)?
i tried jquest closest() method, can't seem work of document.getelementbyid.
element ids should unique. should never have 2 or more elements same id. document.getelementbyid('someid') expecting return 1 element, not array of elements - there other functions available if want multiple elements dont require duplicate ids.
from w3schools:
an id should unique within page. however, if more 1 element specified id exists, getelementbyid() method returns first element in source code.
Comments
Post a Comment