Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Recupero array da form

  1. #1

    Recupero array da form

    Ciao,
    qualcuno sa come modificare questo script, in modo che si possa recuperare il valore dei campi con $_POST di php? In particolare, il valore recuperato deve essere nella forma
    valore1|valore2|valore3.
    Ecco il codice:


    <html>
    <head>
    <script language="Javascript" type="text/javascript">
    <!--
    //Add more fields dynamically.
    function addField(area,field,limit) {
    if(!document.getElementById) return; //Prevent older browsers from getting any further.
    var field_area = document.getElementById(area);
    var all_inputs = field_area.getElementsByTagName("input"); //Get all the input fields in the given area.
    //Find the count of the last element of the list. It will be in the format '<field><number>'. If the
    // field given in the argument is 'friend_' the last id will be 'friend_4'.
    var last_item = all_inputs.length - 1;
    var last = all_inputs[last_item].id;
    var count = Number(last.split("_")[1]) + 1;

    //If the maximum number of elements have been reached, exit the function.
    // If the given limit is lower than 0, infinite number of fields can be created.
    if(count > limit && limit > 0) return;

    if(document.createElement) { //W3C Dom method.
    var li = document.createElement("li");
    var input = document.createElement("input");
    input.id = field+count;
    input.name = field+count;
    input.type = "text"; //Type of field - can be any valid input type like text,file,checkbox etc.
    li.appendChild(input);
    field_area.appendChild(li);
    } else { //Older Method
    field_area.innerHTML += "[*]<input name='"+(field+count)+"' id='"+(field+count)+"' type='text' />";
    }
    }
    //-->
    </script>
    </head>

    <body>
    <form name="frm" method="POST" action="get.php">
    Friends List

    1. <input type="text" name="friend_1" id="friend_1" />
    2. <input type="text" name="friend_2" id="friend_2" />

    <input type="button" value="Add Friend Field" onclick="addField('friends_area','friend_',10);" />

    <input type="submit" name="submit" value="Visualizza l'anteprima e pubblica.">
    </form>
    </body>
    </html>

    Conoscendo poco il javascript non ne sono venuto a una dopo innumerevoli tentativi.
    Help!

  2. #2
    up.
    Help! :rollo:

  3. #3
    Niente?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.