I've got a problem using Javascript (as I'm pretty new into this language)
My problem is : I've got a Javascript script which adds form fields when you click on a button, and change their name by incrementing it.
The data is then stored into an array. When I've saved those filled fields, I need to get them back and show them into a <input type="text" value="<?php $myvalue[] ?>"/>. The problem is, I need to do it into the javascript file, and I don't know how it can interpret the stuff inside as a PHP script.
Here's what I've tried :
var counter = 1;
var limit = 10;
var new_div = '<?php echo json_encode($arraySpecialite['+ counter +']); ?>';
function addInput(divName){
if (counter == limit) {
alert('You cannot add more than' + counter + ' fields');
}
else {
var newdiv = document.createElement('div');
newdiv.innerHTML = 'Specialité ' + (counter + 1) + ' <br><input type="text" name="specialite[]" id="specialite[]"" value="'+ new_div +'">';
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}
Thank's in advance.