Form prefill - form.fieldname(number).value = ''

Hi,

I have a form that has 50 text fields and a corresponding hidden field for each of these.
Ie. textfield1 hiddenfield1 etc.

When the textfield has data entered it calls a script but I want the script to change the corresponding hidden field but am stuck as to how to do this.

I have the following function which gets called:

function addOptions(currentRole)
{
document.addGroup.[‘use_role_’+currentRole].value=‘Y’;
}

Anyone able to help on how to get this work work. Where I have [‘use_role_’+currentRole] the currentRole should be replaced with the number (1 - 50) so as to change use_role_23 if currentRole is 23.

K

why not just add an onchange javascript event to each textfield and pass a variable to it that enters it into the hiddenfield?

<input type=“text” id=“text_input_1” onchange=“changeText(‘1’)”/>
<input type=“hidden” id=“hidden_text_1” />

function changeText(string) {
document.getElementByid(“hidden_text_”+string).value = string;
}

Is that what you are trying to do?

Just to transfer the value to the hidden field, it would be wise to use the onBlur event rather than the onChange. I would suggest to use the above suggested method/way with onBlur event.

agreed, less process intensive!