...

View Full Version : Submitting arrays



Harry
07-11-2003, 06:14 AM
I am using the script shown below to submit multiple forms
with one submit button. All my variables are created
using PHP. The following code works just fine
but if I try to submit a PHP array with a line
like this:

document.formg.array[].value = document.forma.array[].value;

the submit will not work. I'd hate to have to create a separate
variable for each element to submit them and then re-assemble the array on the next page.

Does anyone have an idea how I can do this?

Thank you

Harry



<SCRIPT LANGUAGE="JavaScript">
function copydata()
{
document.formg.text_one.value = document.forma.text_one.value;
document.formg.a_type.value = document.forma.a_type.value;
document.formg.rq_name.value = document.forma.rq_name.value;
document.formg.fl_name.value = document.forma.fl_name.value;
document.formg.emp_stat.value = document.forma.emp_stat.value;
document.formg.emp_id.value = document.forma.emp_id.value;
document.formg.bus_unit.value = document.forma.bus_unit.value;
document.formg.dpt.value = document.forma.dpt.value;
document.formg.brfr.value = document.forma.brfr.value;
document.formg.tt.value = document.forma.tt.value;
document.formg.text_two.value = document.formb.text_two.value;
document.formg.text_three.value = document.formc.text_three.value;
document.formg.text_four.value = document.formd.text_four.value;
document.formg.text_five.value = document.forme.text_five.value;
document.formg.text_six.value = document.formf.text_six.value;
document.formg.oa_0.value = document.formf.oa_0.value;
document.formg.submit();
return false;
}
</SCRIPT>

beetle
07-11-2003, 07:19 AM
This is a common problem. Just use the elements collection of the form

document.formg.elements['array[]'].value = document.forma.elements['array[]'].value;

Harry
07-11-2003, 05:12 PM
Thanks alot for the help. That was just what I was looking for.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum