Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2003
    Location
    Houston, Texas
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Submitting arrays

    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>
    Beyond a critical point within a finite space, freedom diminishes as numbers increase. ...The human question is not how many can possibly survive within the system, but what kind of existence is possible for those who do survive."

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is a common problem. Just use the elements collection of the form

    document.formg.elements['array[]'].value = document.forma.elements['array[]'].value;
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New Coder
    Join Date
    Jul 2003
    Location
    Houston, Texas
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks alot for the help. That was just what I was looking for.
    Beyond a critical point within a finite space, freedom diminishes as numbers increase. ...The human question is not how many can possibly survive within the system, but what kind of existence is possible for those who do survive."


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •