Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert form in table row

Status
Not open for further replies.

aigarzzz

Programmer
Apr 5, 2006
16
LV
i have serious problem. I'm trying to make datagrid like this one - , but i dont understand how i can in table row make form of all cells.
Code:
roomRow[0].innerHTML =
'<input class="editName" type="text" name="name" '+
'value="' + roomRow[0].innerHTML + '">';
roomRow[1].innerHTML =
'<input class="editName" type="text" name="n" ' +
'value="' + roomRow[1].innerHTML + '">';

i change value for each row's cells. I tried to put <form> in first cell and </form> in last, but there is no allowed syntax:
<td>
<form>
</td>
<td>
</form>
</td>

any suggestions?:)
 
The following code should put [tt]<form>[/tt] in the first [tt]<td>[/tt] element on your page, and [tt]</form>[/tt] in the second [tt]<td>[/tt] element(just modify the numbers inside the brackets to place the [tt]<form>/</form>[/tt] tags inside different [tt]<td>[/tt] elements):
Code:
var TdS = document.getElementsByTagName('td');
TdS[0].innerHTML = '<form>';
TdS[1].innerHTML = '</form>';

If you wanted to preserve the information that's already inside the [tt]<td>[/tt] elements, try using something more like (places [tt]<form>[/tt] at very beginning of first [tt]<td>[/tt] and [tt]</form>[/tt] at very end of second [tt]<td>[/tt]):
Code:
var TdS = document.getElementsByTagName('td');
TdS[0].innerHTML = '<form>' + TdS.innerHTML;
TdS[1].innerHTML = TdS.innerHTML = '</form>';




I hope this helps;
Rob Hercules
 
Lol, Dan answered while I was still typing...and his suggestion would probably work better too:
Code:
[tt]var Source_HtmL = '';
SourceHtmL = document.getElementsByTagName('body')[0].innerHTML;

var Table_indeX = SourceHtmL.indexof('<table>');
SourceHtmL = SourceHtmL.subscript(0,(Table_indeX - 1)) + '<form>' + SourceHtmL.subscript(Table_indeX,(SourceHtmL.length - 1));

Table_close_indeX = SourceHtmL.indexof('</table>') + 8;
SourceHtmL = SourceHtmL.subscript(0,(Table_close_indeX - 1) + '</form>' + SourceHtmL.subscript(Table_close_indeX, (SourceHtmL.length - 1));

document.getElementsByTagName('body')[0].innerHTML = SourceHtmL;[/tt]




I hope this helps;
Rob Hercules
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top