This one has me stumped. I have used it this way before but maybe someone else will see something I am not.
function NewPhone(){
var phonediv = document.getElementById('addphone').innerHTML;
var numphone = document.forms["accountfunc"]["numphone"].value;
numphone++;
document.forms["accountfunc"]["numphone"].value = numphone;
NPNHTML = phonediv +
"Phone Number " + numphone + ": <input type='text' name='phone" + numphone + "' size='20'><br>";
document.getElementById('addphone').innerHTML = NPNHTML;
}
<form name="accountfunc" action="index.php?page=newacc&id=<?=$unique_id?>" method="post">
<!--tons of code here-->
<input name="numphone" type="hidden" value="1">
<div id="addphone">
Phone Number: <input type="text" name="phone1" size="20"><br>
</div>
Firefox error
document.forms.accountfunc has no prperties
IE error message
document.accountfunc.numphone is null or not an object
The errors both reference this line from the above code
var numphone = document.forms["accountfunc"]["numphone"].value;
Just so you know what I am doing. This is part of a form that will be for entering new accounts. Some times the accounts have multiple phone numbers. So instead of a bunch of empty fields or not enough fields. I am creating it to generate enough fields per the users specifications. Obviously you can see it will also get and generate a hidden value so the proccesing code knows how many phone numbers will need to be submited and each phone numer field will be getting its own name for that processing.
Now initially the firefox error made me think I had a spelling error in the form name or it wasn't seeing the form in the DOM structure. So rechecked spelling and tried moving the <form> line to see if it would work. I have also tried a few different ways of typing out the variable and it all still gives me the same error.
Any thoughts on this one are appreciated. Maybe I am even just doing it all backwards, feel free to say so.