Well, how about PHP? I think you will need a session variable for this, regardless, and I'm not very familiar with that. As for the AJAX side, using my code that I linked to, you could:
Code:
new loadXmlHttp('somepage.php', 'target_element_id')
on somepage.php, you could increment the session var $vidcount, and have your code (slightly changed because $vidcount should be session and already updated at the beginning of somepage.php, and because getting the tr will be a problem, we will need to make one, we should be able to get the td's though - but even that may mess up, as it will be an invalid HTML code fragment, let's keep our fingers crossed):
Code:
<td><?php echo $vidcount; ?></td><td><input type="text" name="timecode<?php echo $vidcount; ?>" /></td><td><input type="text" name="videocomment<?php echo $vidcount; ?>" /></td><td><input type="text" name="videosuggestion<?php echo $vidcount; ?>" /></td>
If there's a problem with that we can just import the now updated value of $vidcount and build the entire row from scratch, but let's not worry about that right yet.
Now, appending to an existing table is tricky. Make sure your table has a tbody element, and give it a unique id, pass that id as the target_element_id in my above loadXmlHttp function.
Then in the loadXmlHttp.prototype.stateChanged function from my code, you could:
Code:
loadXmlHttp.prototype.stateChanged = function(){
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !loadXmlHttp.re)){
var r = document.createElement('tr'); //creates a tr
r.innerHTML = this.xmlHttp.responseText; //fills it with the td's from the import
this.el.appendChild(r); //appends the new tr to the tbody whose id was passed to the main function
}
}
Bookmarks