A
aidy.lewis
Hi,
Could someone tell me how I can reference a hidden input type using
the DOM?
Aidy
Could someone tell me how I can reference a hidden input type using
the DOM?
Aidy
Could someone tell me how I can reference a hidden input type using
the DOM?
Hi,
Could someone tell me how I can reference a hidden input type using
the DOM?
Aidy
You're hidden input needs to be in the following format:
<input type="hidden" id="myHiddenInput" value="myHiddenValue" />
<snip>Then you may reference is as follows:
var hiddenInput = document.getElementById("myHiddenInput");
alert(hiddenInput.value);
It would be wrong to include the slash at the end in an HTML document
</form></p>
It would be wrong to include the slash at the end in an HTML document
(and as IE browsers do not comprehend XHTML it would not be a good idea
to contemplate writing, and especially scripting, XHTML documents).
Also, an INPUT element without a NAME attribute would not result in a
name value pair being sent to the server if the containing form was
submitted.
<snip>
It is always better to use the W3C HTML DOM specified - elements -
collection of the FORM element to reference the form controls it
contains.
Peter said:I ran into this a few days ago. The W3C validator allows the slash and
is happy without it also.
IE complains only when the XHTML is served as an xml document.
When served as HTML, it can render fine.
Agreed, but the question was with regards to referencing the hidden
input using JavaScript. Server-side processing of the form is a
different story.
<snip>
I would accept this if you could provide an official w3
recommendation that supports it.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.