When trying to select a string value from a hidden input, and adding 1 to it, it doesn't work. It recognizes it as a string, despite my attempts to use parseInt().
For example, everytime I call the function addChild(), the innerhtml that's changed is the following:
Child 1: _________
Child 11: _________
Child 111: _________
Child 1111: _________
Any help is appreciatedCode:<script type="text/javascript"> childDiv = document.getElementById('childDiv'); function addChild() { newChildVal = parseInt(document.getElementById('childTotal').value + 1); document.getElementById('childTotal').value = newChildVal; document.getElementById('childDiv').innerHTML = document.getElementById('childDiv').innerHTML + 'Child ' + newChildVal + ' <input type="text" name="child[]" size="40"><br>'; } </script> <div align="right" id="childDiv"></div> <input type="hidden" name="childTotal" id="childTotal" value="0"> <a href="javascript:addChild()"><font color="Green">Add Child</font></a>![]()



Reply With Quote

Bookmarks