I am trying to get this form to add a distribution line on demand. However, when I click on the 'anotherdistribution' button, I know it is executing the code in moreFields, but it doesn't actually display the fields in the form in the node. Anyone see anything that I am missing?

Thanks,
Karen

<html>
<head>
<title>EFT</title>
</head>
<body>
<div id='readdist' style='display:none' >
<tr>
<td width=10>&nbsp;</td>
<td colspan=4>&nbsp;</td>
<td>* New</td>
<td><input name='newamtnew' style='text-align: right' />
<input type='button' value='Remove Distribution' 
  onclick='this.parentNode.parentNode.removeChild(this.parentNode);'/></td>
</tr>
</div>
<form name='htmlrginputform' method=post action=Post>
<table width=100%>
<tr bgcolor=#DDDDEE>
<td><h2><font color=#3333CC>Distibution</font></h2></td>
</tr>
</table>
<br/>
<br/>
<table width=100% border=1>
<tr><td width=50% colspan=5>&nbsp;</td>
<td width=10%>Stop</td>
<td>New Amount/Information</td>
</tr>

<div><span id='writedist'></span></div>
<tr>
</table>

<br/>
<input type='button' value='Add New Distribution' id='anotherdistribution' onclick='moreFields();' />
</form>

<script language='Javascript'>
  
  function moreFields() {
    var newFields = document.getElementById('readdist').cloneNode(true);
    newFields.id = '';
    newFields.style.display = 'block';
    var insertHere = document.getElementById('writedist');
    var parentDiv = insertHere.parentNode;
    parentDiv.insertBefore(newFields,insertHere);
  }
</script>
</body>
</html>

your problem is because your HTML markup is INVALID. For example, find your first <TR> element. You have not stated where the <TABLE> begins!

Here's another example. If you were to add <table> to fix the problem I mentioned above, then you have: <div><span id='writedist'></span></div> as a child of <table> . A <table> tag cannot have a <div> as a child. You need to put that <div> into a <td> , but that <td> needs to be in a <tr> Go to http://validator.w3.org, and click on "Validate by direct input", then paste your html. Fix all the errors outlined there and then your page should work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.