'onfocus' won't work inside dynamic generated <input> line
Posted: Mon Jan 30, 2012 6:20 pm
I am generating a table to be used as a revision form. One <input> line contains: onfocus='showDisplayName(x,y)'. The purpose of this is to produce a standardized input of 'last_name, first_name'. This works fine in a regular HTML form context, but does not work in the dynamically created form. I would appreciate any help in making this work. Thanks in advance, RP.
Generated Table Output:
Generated HTML Code: My Source Code:
Generated Table Output:
Generated HTML Code: My Source Code:
Code: Select all
foreach($connectData as $key => $value) {
$k[]=$key;
$v[]=$value;
if($key=='Name_ID') {
continue;
};
printf("<td><label for='%s'>%s</label></td>\n",strtolower($key), preg_replace("/_/"," ",$key));
if($key=="Display_Name") {
printf("<td><input type='text' name='%s' onfocus='showDisplayName($v[1], $v[2]);'
id='%s' value='%s'></input></td></tr>\n", strtolower($key), strtolower($key), $value);
continue;
};
if (contains($key, "Notes")) {
printf("<td><textarea name='%s' id='%s' rows=5 cols=81> '%s' </textarea></td></tr>\n",strtolower($key),
strtolower($key), $value);
continue;
};
printf("<td><input type='text' name='%s' id='%s' value='%s'></input></td></tr>\n", strtolower($key), strtolower($key), $value);
}; // if key
printf("</table></form></fieldset></div>\n");