1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| function NPK_reg()
{
//var chaine="19,5-20-88Euralis";
//var chaine=document.getElementById('texteTEST').value;
var chaine=document.getElementById('id_engrais').options[document.getElementById('id_engrais').selectedIndex].text;
//chaine=chaine.replace(/[^\d,-]+/g,'');
chaine=chaine.replace(/,/g,'.');
var reg=/(\d+\.?\d+?)-(\d+\.?\d+?)-(\d+\.?\d+?).*/g;
var NPK = reg.exec(chaine);
for (var i=0; i<NPK.length; i++)
{
var newinput= document.createElement('input');
newinput.setAttribute("size", "5");
newinput.setAttribute('onkeyup', 'Calculer()');
newinput.setAttribute('onload', 'Calculer()');
newinput.setAttribute("name", "N"+i);
newinput.setAttribute("type", "text");
newinput.setAttribute("value", NPK[i]);
newinput.setAttribute("id", "N"+i);
document.getElementById('NPK_id').appendChild(newinput)
}
} |