mercredi 4 avril 2018

Appended element goes undefined when being passed over

Hi i have this code where everclick appends a DOM element where the user can pick what he wants then submits it to another page.

<form action="view.php" method="post>
<textarea name="paragraph[]'></textarea><input type="button" onclick="addparagraph();" value="+"></input>
<select name="font[]"><option>Tohoma</option><option>Arial</option>
<div id="firstpart"></div>  
<input type="submit" value="submit"/>
</form>
<script>
function addparagraph(){
var string = '<textarea name="paragraph[]'></textarea>'+
             '<select name="font[]"><option>Tohoma</option><option>Arial</option>';
             jQuery('#firstpart').append(string);
               }

once submitted it does not get the value of the appended elements

here is the view.php part

foreach($_POST['paragraph'] as $count => $value){

    echo "$value";

    echo "$_POST['font'][$count];

}

it appends the elements but it does not display the values of the appended array.. it gives an error offset undefined




Aucun commentaire:

Enregistrer un commentaire