Getting elements with same name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • traineeirishprogrammer
    New Member
    • Jul 2007
    • 24

    Getting elements with same name

    I am creating a dynamic form in which you can add elements with javascript. This works fine.

    Every time I click add new element >

    I.E.
    [code=javascript]
    cell_3.innerHTM L = "<select name='team_A' id='team_A"+las tRow+"'></select>";
    [/code]
    With Dom I can access all elements with name team_A like this team_A[0] ,team_A[1] and so on later.

    However can I access every element through $_GET[team_A[0]] or $_POST command or will I have to name every element seperately.

    Hope you can understand what I am on about.
  • ilearneditonline
    Recognized Expert New Member
    • Jul 2007
    • 130

    #2
    Originally posted by traineeirishpro grammer
    I am creating a dynamic form in which you can add elements with javascript. This works fine.

    However can I access every element through $_GET[team_A[0]] or $_POST command or will I have to name every element seperately.
    Hope this helps. Probably not exactly what you were looking for but may help u get started.
    [CODE=html]
    <?php
    if (isset($_POST["submitform "]))
    {
    foreach($_POST['myselect'] as $key => $value)
    {
    // do something
    }
    }
    ?>

    <form action="testfor m.php" method="POST">
    <select name="myselect[]">
    <option value="MD">Mary land
    <option value="PA">Penn sylvania
    </select>

    <select name="myselect[]">
    <option value="US">Unit ed States
    <option value="UK">Unit ed Kingdom
    </select>

    <input type="submit" value="submitfo rm" name="submitfor m" />
    </form>[/CODE]

    Comment

    Working...