Hidden inputs

User 515127 Photo

Registered User
112 posts

I have been hand-coding a lot of form content over the past year because I didn't realize that I could do enough of the work within RSD to make it worthwhile to explore that option.

Lately I've been on a quest to reduce the time-consuming complication that hand-coding this stuff introduces - particularly when the need arises to change the appearance of the page in RSD. If all you have is a contact form... no worries, but once you start dealing with multiple forms, interactive forms - life gets considerably more complicated.

Creating a hidden input seems straightforward - insert the element and set the display property to none. Then create a custom attribute of value and set ... oop's, I cannot add value as an attribute. RSD says - reserved property name.

Necessity being the mother of invention, I Google the obvious query - How do I set a default value for an HTML form element, looking for alternatives, but already resigning myself to adding another line into the onload event to poke the desired value into the element. document.getElementById('hiddeninput').value = 0. The trouble with doing that - six months or a year later - you may modify the form or the code and if that gets disconnected it can give you a sneaky javascript fail or cause the form to functionally fail whenever the circumstance that required that value be set, occurs.

Imagine my surprise when the search results say... (not in these exact words but...) Well stupid, assign the attribute defaultValue = "whatever" Doh!

I need to sit down with the HTML5 and CSS3 and seriously study the appendix of properties etc. I keep reinventing wheels that have already been provisioned. As a far wiser fellow than me named Lincoln is alleged to have said, "Give me six hours to chop down a tree and I will spend the first four sharpening the axe." ---Abraham Lincoln

Thought I'd post this just in case someone else needs to set a defaultValue and didn't know that they could simply do exactly that within RSD by assigning that as an attribute.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.