Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Not getting the form
05-31-2013, 11:20 PM #1
- Join Date
- Apr 2008
- Thanked 0 Times in 0 Posts
Not getting the form
i have a strange behavior on my webpage on my local computer.
i have 2 forms. One of them is defined as following:
<form class='form-validate view' id='siteForm' name='siteForm' method='post' action='<?php echo $url; ?>' > <!-- blah, blah --> <a class="delete" href="#" title="Delete selected records" onclick="alert(document.siteForm.boxchecked.value);"> <span class="trash-icon"></span> </a> <!-- blah, blah --> <input type="hidden" name="boxchecked" value="" /> </form>
- if user click on the link, the alert message does not display any data... (the code on onclick is just temporary)
if i want to retrieve the value and display it correctly, i must use:
it's like js is not able to find the siteForm form object
05-31-2013, 11:49 PM #2
Well, just for starters, named <form>s *ARE* obsolete.
Which means that the the construction
document.siteFormis also obsolete.
I don't know of any browser that actually enforces this--all that I have used still support
document.siteForm--but possibly you have run into a browser that is enforcing the obsolescence?
In short, I wouldn't worry too much about it because
document.getElementById('siteForm')is the correct modern coding. And kill the name= in your <form> tag.
Possible reason: Although IDs must be unique on a page, names do not need to be unique, at all. However, if you have multiple objects with the same name, then JS will treat them as an array.
Perhaps you have *another* object on the page with that same name?
An easy way to find out:
alert( document.siteForm.length );
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.