Current location: Hot Scripts Forums » General Web Coding » JavaScript » how to pass values from form to a table?


how to pass values from form to a table?

Reply
  #1 (permalink)  
Old 03-30-04, 03:29 PM
vusubhashini vusubhashini is offline
New Member
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question how to pass values from form to a table?

Hi friends,

I have attached the coding for passing the value from a textbox to a table. Like this, i would like to know on how to add multiple textbox in multiple fields in one table?

<html>
<head>
<script>
function addToTable() {
var value = document.getElementById("txtBox").value;
var tr = document.createElement("TR");
var td = document.createElement("TD");
var td1 = document.createElement("TD");
var td_value = document.createTextNode(value);
td.appendChild(td_value);
tr.appendChild(td);

document.getElementById('tb').appendChild(tr);
}
</script>
</head>

<body>
<input type="text" name="txtBox" id="txtBox"/>

<button onClick="addToTable()">add</button>

<table border=2>
<tbody id="tb">
<th>List</th>
<th>Name</th>
</tbody>
</table>

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 03-31-04, 01:30 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Do you mean that each textbox represents a cell in a row that will be created when clicking Add?

if so, you could just make the function create more textNodes and TD:s and then append them to the TR...

I usually use .innerHTML or document.insertAdjacentHTML("beforeEnd",code) for something like that though.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formmail problem gscraper Perl 12 08-27-04 03:06 AM
form doesn't submit to mysql correct values, just 1's in every row HasansWeb PHP 1 01-12-04 07:40 AM
Replicating table MySQL values lordmerlin PHP 2 01-06-04 11:15 AM
Collecting html form data and sending it to a sql table crobinson ASP 3 01-04-04 09:16 PM
passing values from one form to another -urgent aspuser25 ASP 1 09-19-03 06:41 PM


All times are GMT -5. The time now is 02:14 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.