I have a table within a form that looks like this:

Form with Table

The HTML and JavaScript

<table border="1" id="tblSample">
    <td><input type="text" name="txtRowa1"
     id="txtRowa1" size="5" /></td>
    <input type="text" name="txtRowb1"
     id="txtRowb1" size="15" />    </td>
    <input type="text" name="txtRowc1"
     id="txtRowc1" size="15" />    </td>
    <td><input type="text" name="txtRowa2"
     id="txtRowa2" size="5" /></td>
    <input type="text" name="txtRowb2"
     id="txtRowb2" size="15" />    </td>
    <input type="text" name="txtRowc2"
     id="txtRowc2" size="15" />    </td>
    <td><input type="text" name="txtRowa3"
     id="txtRowa3" size="5" /></td>
    <input type="text" name="txtRowb3"
     id="txtRowb3" size="15" />    </td>
    <input type="text" name="txtRowc3"
     id="txtRowc3" size="15" />    </td>

<input onclick="formSubmit()" type="button" value="Send data" />

<script type="text/javascript">
        function formSubmit() {

This table needs to be put on a spreadsheet, the gs file is:

function getValuesFromForm(form){
  var tempa1 = form.txtRowa1,
  tempb1 = form.txtRowb1,
  tempc1 = form.txtRowc1,
  tempa2 = form.txtRowa2,
  tempb2 = form.txtRowb2,
  tempc2 = form.txtRowc2,
  tempa3 = form.txtRowa3,
  tempb3 = form.txtRowb3,
  tempc3 = form.txtRowc3,
 sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
 sheet.appendRow([tempa1, tempb1, tempc1]);
 sheet.appendRow([tempb1, tempb2, tempc2]);
 sheet.appendRow([tempc1, tempc2, tempc3]);

But the thing is: the table is dynamic and i dont know how many rows is going to have (in this case there are 3 rows) How do I get the values out of the table?