Hi,
haven't tested this, but have had to use something similar on a really big form recently.
You need to use a particular naming structure for your fields. Call the text boxes "Q1" - change the 1 to the right question number each time - then call your drop down boxes
"Q1a" "Q1b" "Q1c".
It's easier to make reusable code then. Stick this lot in a
function and call it onChange:
Code:
for (i=0; i<formname.length; i++)
{
if (formname.elements[i].type == "text")
{
str = formname.elements[i].id;
str1 = eval ("formname." + str + "a");
str2 = eval ("formname." + str + "b");
str3 = eval ("formname." + str + "c");
formname.elements[i].value = str1.selectedIndex.value
+ str2.selectedIndex.value
+ str3.selectedIndex.value;
}
}
If you want to use other text boxes in the form that
aren't linked to select fields, do
Code:
if (formname.elements[i].type == "text")
&& (formname.elements[i].id !== "elementname")
You also need to remember that 'id' only works in Internet
Explorer, if you want it to work in Netscape etc. as well,
you have to write a second version using 'name' instead of
'id', and use a browser sniffer to see which version the
client is using. (Make sure you put both name and id in the
element tags in this case).
Hope that helps, if there are any bugs, it's likely to be
with the value of your select elements (drop down boxes) not being recognised as a number. In any case, post back if
there are problems, and I'll try to sort them out!
fingerprint
a posse ad esse