Hey All,
I have 20 odd HTML pages for which I am converting to facilitate dynamic forms generation. Each page contains a hundred or so text fields, which I need to convert (with deference to each elements ID# and size="value") as follows.
FROM:
<input type="text" id="drop_d1" onfocus="show('dropDiv_d1');" onchange="this.form.elements['dropCB_d1'].checked=(this.value!='')?1:0;" onblur="show('dropDiv_d1');" name="drop_d1" size="13">
<input type="text" id="drop_d2" onfocus="show('dropDiv_d2');" onchange="this.form.elements['dropCB_d2'].checked=(this.value!='')?1:0;" onblur="show('dropDiv_d2');" name="drop_d2" size="20">
TO:
<?php make_comboBox(1,1,13);?>//(inputType,idNo,Size)
<?php make_comboBox(1,2,20);?>
I was hoping to script this conversion, but I'm really struggling to see a way. something like:
<?php
function replace_elements(){
foreach($textInput as $value)
// though I don't see how to filter/find each in midst of much HTML
{
$string = '$value';
$pattern = '/(\w+) (\d+), (\d+)/i';//need help with regexp pattern here.
$replacement = '<?php make_comboBox(1,"$idNo","$size")';
preg_replace($pattern, $replacement, $string);
}
}
?>
Please, is something like this possible via php, or is there perhaps an inexpensive editor out there that allows for this kind of sophisticated find and replace operation?