G
GTalbot
sub print_javascripts {
print "<script LANGUAGE=\"Javascript\" type=\"text/javascript
\">var n = 0</script>\";
print "<script LANGUAGE=\"Javascript\" type=\"text/javascript\">
Language is deprecated. Type is required, good.
Javascript Best Practices
http://www.javascripttoolbox.com/bestpractices/#script
function addRow(id){
n++;\"
var str = 'item' + n;
var tbody = document.getElementById(id).getElementsByTagName
(\"tbody\")[0];
var row = document.createElement(\"tr\");
var input = document.createElement('input');
input.type = 'text';
input.name = 'str';
input.size = 50;
input.maxlength = 256;
It's maxLength, not maxlength
http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-54719353
var data = document.createElement(\"td\");
data.appendChild(input);
row.appendChild(data);
tbody.appendChild(row);
} </script>";
}
As you can see,
Ted, it would have been utterly relevant to provide an url with only
the involved javascript. Then, you would have gotten useful help from
this newsgroup.
Second question, I wrote this on the assumption that text input fields
have to have unique names. Is this assumption correct, or can I give
all the text input fields in this table the same name,
document.getElementsByName is pretty buggy in IE (all versions). So,
all text input with the same name is not an recommendable option.
Finally, such script will most likely not work in IE 6 and IE 7 (too
buggy). You can recommend your visitors to upgrade or to switch here.
Gérard