Friday, December 04, 2009

What a relief today!

It's Friday - what a relief!

I've been working on a special maintenance feature for a web application at work. I have an entry form and a display form. The user enters an order for copies of a document with paper style, color, covers and what not. The people receiving the order view it with the display form.

Well all of the "select" type fields were translating fine using selectedIndex.text, but NOT the checkbox fields. Seems I couldn't get the text out of those no matter what I did. I didn't want the value - that's only used to add up the order estimates.

I finally figured it out this morning - and wanted to whoop and holler!

So for any techies out there - and poor non-techies can try to muddle thru, here is a code fragment that gets the basic concept across:

"

docfinishingField = "finishing_" + (f-1);
docStorefinishing= "doc" + f + "_finishing";
//save values for display form
ftype = document.getElementById(docfinishingField).type;
if (ftype=="checkbox"){
for (var c = 0; c <>
if(document.forms[0][docfinishingField][c].checked){
// alert("test nodeValue: " + document.forms[0][docfinishingField][c].nextSibling.nodeValue);
frm[docStorefinishing].value = frm[docStorefinishing].value + document.forms[0][docfinishingField][c].nextSibling.nodeValue + ",";
}
}
}

"
I am so happy to have THAT figured out. Then someone on my team overheard me discussing the solution and wanted the code too as they had been having the same trouble!

So - whoopie!!! It was a pretty good day, but I am so thankful for the weekend!

No comments: