Looping through multiple formfields with javascript?
I have a script where I can PregReplace something in a string with a defined value from my input field and it works like a charm.
PHP Code:
echo '<input id="pfrom" type="text" value="" name="pfrom">';
Code JavaScript:
function demoRegex(){
var txt = document.newform.thestring.value;
var re = new RegExp(document.newform.pfrom.value, "g");
newtxt = txt.replace(re,'');
alert(newtxt);
}
But what if I have multiple input field like this:
PHP Code:
foreach($arr as $arr1=>$value){
echo '<input id="pfrom" type="text" value="" name="pfrom[]">';
}
How do I get the javascript to run through all the fields?
Hoping for help.... Thanks in advance ;-)