.NET Framework Bookmark and Share   
 index > JScript for the .NET Framework > document.write
 

document.write

Hi, I'm from Argentina.

I have 2 textfields and 1 button.

In the first textfield I enter something and must be shown with the following default HTML Table on the second multiline texfield when I click the button.

HTML table (must be inside the script):

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Here goes what I enter in the first text field </td>
</tr>
</table>

Can this be done with document.write? I'm not an expert with javascript.

Thanks from Argentina !
Martín Carreras
you can do that with DOM.

I still didnt get your question clearly though. If you want something to come in t table cell, you must identify it.

Suppose you have the Table object, you can use its id property to get the control's reference in javascription (using document.getElementById('ID');

<script type="text/javascript">
    function btnClick_Click()
    {
    var enteredText = document.getElementById('txtInput').value;
    var tbl = document.getElementById('tblData');
    var TBody = tbl.firstChild;
    var Trow = TBody.firstChild;
    var TableCell2 = Trow.firstChild.nextSibling;
	TableCell2.firstChild.nodeValue = enteredText;
    }
    </script>
  </head>
  <body MS_POSITIONING="GridLayout">
	
    <form id="Form1" method="post" runat="server">
	<input type="text" id="txtInput" >
	<input type="button" id="btnClick" value="Click Me" onclick="btnClick_Click()" />
	<table border="1" id="tblData">
	<tr>
	<td>TestData1</td><td>TestData2</td>
	</tr>
	</table>
    </form>

Ganesh Ranganathan
[Please mark the post as answer if you find it helpful]
Ganesh Ranganathan - Bangalore, India
you can do that with DOM.

I still didnt get your question clearly though. If you want something to come in t table cell, you must identify it.

Suppose you have the Table object, you can use its id property to get the control's reference in javascription (using document.getElementById('ID');

<script type="text/javascript">
    function btnClick_Click()
    {
    var enteredText = document.getElementById('txtInput').value;
    var tbl = document.getElementById('tblData');
    var TBody = tbl.firstChild;
    var Trow = TBody.firstChild;
    var TableCell2 = Trow.firstChild.nextSibling;
	TableCell2.firstChild.nodeValue = enteredText;
    }
    </script>
  </head>
  <body MS_POSITIONING="GridLayout">
	
    <form id="Form1" method="post" runat="server">
	<input type="text" id="txtInput" >
	<input type="button" id="btnClick" value="Click Me" onclick="btnClick_Click()" />
	<table border="1" id="tblData">
	<tr>
	<td>TestData1</td><td>TestData2</td>
	</tr>
	</table>
    </form>

Ganesh Ranganathan
[Please mark the post as answer if you find it helpful]
Ganesh Ranganathan - Bangalore, India

You can use google to search for other answers

Custom Search

More Threads

• .JS/.ASP differences between IIS5 and IIS6
• [Help] How to write a string below a specific string in text file?
• GridView - OnClientClick
• README - read this first to get your question to where it will be answered
• object reference is not set instance of object
• How to Disply image in HTML from from SQL server
• Document.InvokeScript
• does ICodeCompiler need SDK?
• Convert Jscript to VBscript
• JScript error Object doesn't support the property or method