The picklists would be something like this:
Value / Label
1 A little
2 More
3 A lot
(Default is nothing selected)
Each question is an attribute and the names are like this:
new_0101
new_0201
new_0301
new_0102
new_0202
and so on...
I would like to run through all the questions (fields) and sum up the
values representing the answers, but I can't figure out howto retrieve
the values, when I loop though the field names like my example
hereunder - please help...!
var i;
var t;
var fieldname;
var fieldvalue;
for (i=1; i<=75; i+
+) // 75
questions...
{
t = ((i<10) ? "0" : "") +
i; // If i>0 the put at
0 in front of i
fieldname = 'new_' + t +
'01'; // the field name could
then be fx "new_0102" or "new_0202" and so on
fieldvalue = document.getElementById('fieldname').Value; // Here's
my problem - I've tried many different versions of getElementBy... but
with no luck...
alert
(fieldvalue); //
just to monitor if I got the value or not...
// the math will come here - and is allready working if I manually
retrieve the field values in 75 single lines...
}
Hi,
There is just one bug in your code:
Should be:
fieldvalue = document.getElementById('fieldname').value;
instead of:
fieldvalue = document.getElementById('fieldname').Value;
"value" not "Value"
Regards,
Dawid Kołodziejczyk
http://team4crm.com
One more thing...
If you build field name dynamicly in variable "fieldname" you should
omit apostrophe in getElementById(). I should look like:
fieldvalue = document.getElementById(fieldname).value;
Regards,
Dawid Kolodziejczyk
http://team4crm.com