« What we've all been waiting for! | Main| Jabber, Inc. Introduces SIP/SIMPLE Microsoft Interoperability Gateway for Microsoft LCS »

Domino bit me yesterday...

Category
No not Bruce's dog, I mean Domino the product. I had been doing some JavaScript work, and manipulating some hidden fields, all worked great in IE, then on to making it work with Firefox. Shouldn't be a problem I thought. Well it turned out it was. IE seems to be quite happy to treat fields that have a name defined but no id, where as, Firefox wants id's and doesn't seem to really care about names (probably something to do with standards).

Anyway after figuring out the problem was that the hidden field didn't have an id assigned, I thought it would be easy to fix, just add the name to the id field on the form properties. No joy it never appeared, hhm time to investigate, turns out if the field is hidden Domino doesn't appear to push those properties out even though it creates the field. So I still wanted the field hidden but I needed the id tag to be there and populated. After trying a few solutions here is the one I came up with, place the field unhidden within the following HTML, this will make Domino honour the extra field properties, but not display the field to the end user.

<span style="display:none">DOMINOFIELDHERE</span>

Did I miss a simple form property somewhere? Is there an easy way for Domino to honour the id tag for hidden fields?

Comments

Gravatar Image1 - When attempting the same, I've taken to inserting "display:none" into the style property of the field. This essentially has the same result as enclosing the field in a span, but lists the style change as a property of the field, keeps the rest of the field properties intact (including id), gives the flexibility of displaying other information in the same paragraph, and makes the source more readable than hiding a field using hide-whens because it leaves the html for the field right where you put it. This is particularly useful if you want to hide fields temporarily until they're needed, then use JavaScript to display them later, which is trickier to do when using spans.

Gravatar Image2 - @1. I like that.

Gravatar Image3 - Another way is to deselect "generate HTML for all fields", and under HTML attributes put "Type=Hidden"...

Gravatar Image4 - You have to place type="hidden" in the "other" field of the html tab. Then the id will be used and the field will be hidden.

Gravatar Image5 - You can use 3. or 4. for editable fields, but if you want the field to be computed and still readable for JavaScript i normally use:
<input name="Fieldname" type="hidden" value="Put computed text or field here">

Gravatar Image6 - Thanks everyone, I like all these suggestions!

Gravatar Image7 - Then as a final step automate the creation of the ID attributes. Domino by default only creates NAME attributes and having to add ID manually is both tedious and a good source of errors. So I include a function that I call in the onload of the page:
function initdocument() {
/* Adjust element name= with id=;
In IE GetdocumentByID works on id= and on name=; in Mozilla (and others) you MUST have ID */
var collection = null;

if(typeof document.all == "object") {
collection = document.all }
else {
if(typeof document.getElementsByTagName == "function"
&& document.getElementsByTagName("*").length > 0) {
collection = document.getElementsByTagName("*");
}

if(collection == null) return; // Cancel if it didn't work

for(var i = 0; i < collection.length; i++) {
// Check for a name and then for an ID
if (collection.name) {
collection.id = collection.name;
}
}
};

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)