Greetings. I've made a system whereas client can input tracking via an online system of forms. I need them to be able to submit forms line by line (which will eventually be triggered by a tabout).

I'm using the following code with success:

Code:
<script type="text/javascript" language="javascript">
   var http_request = false;
   function makePOSTRequest(url, parameters) {
   
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
			
			id = document.getElementById('video_id').value;
            result = http_request.responseText;
            document.getElementById('myrow'+id).innerHTML = result;           
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
      var poststr = "video_id=" + encodeURI( document.getElementById("video_id").value ) +
	  					"&spin_dates=" + encodeURI( document.getElementById("spin_dates").value ) +
						"&total_spins=" + encodeURI( document.getElementById("total_spins").value ) +
						"&comments=" + encodeURI( document.getElementById("comments").value ) +
						"&name=" + encodeURI( document.getElementById("name").value ) +
						"&artist=" + encodeURI( document.getElementById("artist").value ) +
						"&comp=" + encodeURI( document.getElementById("comp").value ) +
                    "&program_id=" + encodeURI( document.getElementById("program_id").value );
      makePOSTRequest('trackhandle.php', poststr);
	
   }
   </script>
</head>

<body>
	<?php
	if(isset($_SESSION['admin'])) { 
	include 'includes/adminnav.php'; 
	}
	
	//if(!isset($_SESSION['admin'])) {
	?>
	
	
		<table>
			<tr>
				<th>Video Name</th><th>Artist</th><th>Comp</th><th>Spin Dates</th><th>Total Spins</th><th>Comments</th><th></th>
				<?php $sql = mysql_query("SELECT * FROM videos ORDER BY id DESC") or die(mysql_error());
					while($row=mysql_fetch_array($sql)) {
					
						$done = mysql_query("SELECT * FROM tracking WHERE video_id = '".mysql_real_escape_string($row['id'])."' AND program_id = '".mysql_real_escape_string($_SESSION['user_id'])."' AND date >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)") or die(mysql_error());
						if(mysql_num_rows($done) == 0) {
						?>
						<form method="post" name="myform<?php echo $row['id']; ?>" id="myform<?php echo $row['id']; ?>" action="javascript:get(document.getElementById('myform<?php echo $row['id']; ?>'));">
						<input type="hidden" name="video_id" id="video_id" value="<?php echo $row['id']; ?>" />
						<input type="hidden" name="program_id" id="program_id" value="<?php echo $_SESSION['user_id']; ?>" />
						<input type="hidden" name="name" id="name" value="<?php echo $row['name']; ?>" />
						<input type="hidden" name="artist" id="artist" value="<?php echo $row['artist']; ?>" />
						<input type="hidden" name="comp" id="comp" value="<?php echo $row['comp']; ?>" />
						<?php 
						echo "\n<tr id=\"myrow$row[id]\" valign=\"top\"><td>$row[name]</td><td>$row[artist]</td><td>$row[comp]</td><td><input type=\"text\" id=\"spin_dates\" name=\"spindates_$row[id]\" size=\"25\" /></td><td><input type=\"text\" id=\"total_spins\" name=\"totalspins\" size=\"6\" /></td><td><textarea id=\"comments\" name=\"comments_$row[id]\"></textarea></td><td><input type=\"button\" name=\"button\" value=\"Submit\" 
   onclick=\"javascript:get(this.parentNode);\"></td></tr>\n";
						?>
						
						
						</form>
						<?php 
						}
					
					}
				?>
				
			</tr>
		</table>
	</form>
Upon successful form entry - the user's results replace the original form line. My problem is that only the very first line was being replaced (ie: not the line of the just completed form). This being the case after the very first submission each following form stays the same and doesn't turn into the result.

As you will see this is the code that swaps out the form for its results:

Code:
   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
			
			id = document.getElementById('video_id').value;
            result = http_request.responseText;
            document.getElementById('myrow'+id).innerHTML = result;           
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
I need to pass some type of variable to the script which line it needs to replace.

Thanks for any help!