Click to See Complete Forum and Search --> : Table doubt


saju_m
01-28-2003, 11:32 PM
hi,

my doubt is,

i'm having a table with 3 rows and 3 columns and a button outside the table.

now.. by clicking the button the first row should be filled with text boxes( i mean one textbox in one cell, like that three textboxes).

now if i click once again the textboxes in the firstrow should be cleared and it should appear in the second row.

one more click second row's textboxes vanishes and appears in the third row.

please help me solve this...urgent requirement, pls.

lakshman
05-13-2003, 03:02 AM
Hi All,

I used this technique to enter data in a table.
But, HOW do I retrieve the value of "myText"

var oTBody = document.getElementById("tableID");
var rows=oTBody.rows
var tblCells = rows[0].cells

Some of my last tries are :
alert (rows[0].namedItem("myText").value);
alert (rows[0].myText.value);
alert (tblCells[0].item(0).tagName);


I have tried for half a day and I am going mad.

Please...Please...Please Help

lakshman
05-13-2003, 09:45 PM
Thanks for that Dave.

The following command does not work.
alert ("rows[0].id : " + document.frmTab.rows[0].id);


The following command works.
alert ("rows[0].id : " + rows[0].id);


Why and How???


Could you also tell me whether the following should work. I am getting "document.frmTab.rows.0 is null or not an object"

alert ("rows[0] : " + document.frmTab.rows[0].intitle.value);
The above alert is in line 255 under the function includeCustomerDetails().

If the above is correct then I can lnvestigate other parts of my file for errors.

I think the table is not created withing the form. Not sure..!!

I have attached my source file
you may, if you have time, search for "frmTab" & "tblAddresseeDetails_tBody" to validate that the table is within the form.


Please help....

lakshman
05-13-2003, 10:51 PM
Hi Dave,

Thanks for that response. Yes frmTab is the form Name, Here is the code snippet.

Note : addCust function adds a new row when the user hits a "add Cust Button"

When the user submits the form includeCustomerDetails gets called.

<body >
<form name="frmTab" method="post">
.
.
.
<table height=380 width=775 border=0>
<tr height=95% valign="top">
<td>
<table name="tblAddresseeDetails" id="tblAddresseeDetails_Id" striped="true" class=rowover border=1>
<thead BGCOLOR="lightskyblue" >
<tr >
<th width=50>Title</th>
<th width=205>Given Name</th>
<th width=320>Common Name</th>
</tr>
</thead>
<tbody id="tblAddresseeDetails_tBody">
</tbody>
<tfoot>
</tfoot>
</table>
</td>
</tr>
<tr>
<td>
<input name="btnAddCust" type="button" value="Add" onclick="addCust()">
</td>
<td>
<input name="customerString" type="hidden">
</td>
</tr>
</table>
.
.
.
</form>
</body>



<script language="JavaScript">
function addCust()
{
//alert("Add Cust Called");
var strTitle = '<input type="text" name="intitle" size="4">';
var strFName = '<input type="text" name="infName" size="30">';
var strCName = '<input type="text" name="incName" size="50">';

var oTBody = document.getElementById("tblAddresseeDetails_tBody");
oTR = oTBody.insertRow();
oTR.id = rowId++;
oTD = oTR.insertCell().innerHTML = strTitle;
oTD = oTR.insertCell().innerHTML = strFName;
oTD = oTR.insertCell().innerHTML = strCName;
}



function includeCustomerDetails()
{

document.frmTab.customerString.value="Mrs~Kumuthiny~Srilakshmanan|Mast~Krishna|Mast~Kanna";
//alert ("Called includeCustomerDetails");
var oTBody = document.getElementById("tblAddresseeDetails_tBody");
var rows=oTBody.rows
alert ("Pass 2");

alert ("rows[0].id : " + document.frmTab.rows[1].id);
//alert ("rows[0].id : " + document.frmTab.rows[0].intitle.value);
//alert ("tblCells[0] : " + tblCells[0].item(0).tagName);
//for(i=0; i < rows.length; i++)
//{
// document.frmTab.customerString += rows[i].strTitle + "~";
// document.frmTab.customerString += rows[i].strFName + "~";
// document.frmTab.customerString += rows[i].strCName + "~";
// document.frmTab.customerString += "|";
// }

// Remove the trailing "|"
//document.frmTab.customerString.substring(document.frmTab.customerString.length-1, document.frmTab.customerString.length);
//alert("List of Customer String : " + document.frmTab.customerString);
}
</script>


Any help will be much appreciated.

lakshman
05-15-2003, 01:43 AM
Hi Dave,


Is that what you're trying to figure out? ...what field to reference for a particular table row?


Yes... Yes.. Oh Yes... Please..Please tell me the secret.

Lakshman