Quote:
Originally Posted by nc3b
Code:
document.getElementById("amount").value=your_counter;
Do that before submitting the form. Add id="amount" to the hidden field parameters.
Usually I would replace the submit button with a button that triggers (onclick) a function which first does that and then submits the form (which by the way should have a name and id, just like the hidden field).
|
Thanks a million! You managed to get my script moving along with that. My PHP script is in fact receiving the dynamic value via POST now. Even though it is working, I have a feeling I might not have done it properly. I'm gonna post what I ended-up with in hopes that you (or anyone else) might have a look at it and provide some feedback if you can. BTW, if you could elaborate a bit about the form's need for
name and
id it would be greatly appreciated.
The top of my form still looks like:
Code:
<form action="confirmation.php" method="post">
The bottom of my form now looks like:
Code:
<input type="hidden" id="amount" name="amount" value="" />
<input type="submit" OnClick="getCount(amount);" value="Submit!" />
</form>
My
javascript.js file now looks like:
Code:
var count = 3;
function insRow()
{
var x = document.getElementById('myTable').insertRow(count);
var a = x.insertCell(0);
var b = x.insertCell(1);
var c = x.insertCell(2);
a.innerHTML = "<TUXRULES>" + (count) + "<TUXRULES>";
b.innerHTML = "<TUXRULES>" + (count) + "<TUXRULES>";
c.innerHTML = "<TUXRULES>" + (count) + "<TUXRULES>";
count++;
}
function getCount()
{
document.getElementById("amount").value = count-1;
}
For clarity, I replaced all the HTML parts with <TUXRULES>. The counter starts at 3 due to the fact that the table starts with two rows, so I need it to start inserting rows after that point (whenever the user clicks "Add row"). Notice how in the
getCount() function I subtracted 1 from the counter in order to get the total number of rows deployed.
Happy New Year to you also! And once again, thanks for the help!