?
Solved

Collect data and add to table

Posted on 2009-02-17
4
Medium Priority
?
647 Views
Last Modified: 2012-05-06
Trying to find a way to collect data on a screen and when user clicks a add button, drop it into a table below it.  Then user could repeat the process over and over until finished.   Once user is finished, will click a submit button and then will send to a java servlet which will process all the new requests.

I know I could do a submit button then send to servlet and the wrap around back, but trying to cut down on the network traffic and also make the application more user friendly.  Using java and jsp's.

Example:

Name:
Address:
State:

ADD BUTTON

Then on same form,  a table below it which will show each time the user adds another user.  

Name                       Address                       State
John Smith               114 N. Ash                   MO
Fred Flintstone         2912 S. Willow            KS

SUBMIT BUTTON
0
Comment
Question by:TheVeee
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
zkeown earned 2000 total points
ID: 23661266
Not tooooo hard.  For your Add button, first, get a reference to your table... the easiest way is to give it an ID.

var dataTable = document.getElementById("MyTable");

Then use the insertRow method to add a new row to the table.  You'll want to both display the values you're getting from the Name, Address, and State fields as well as putting the values into hidden fields on each row (so they'll actually submit).

The basic idea is:

var newRow = dataTable.insertRow(0);
var newColumn = newRow.insertCell(0);
newColumn.innerHTML = valueFromYourFields;
newColumn.innerHTML += "<input type=\"hidden\" name=\"identifier\" value=\"" + valueFromYourFields + "\" />";
0
 
LVL 5

Author Comment

by:TheVeee
ID: 23661577
Sorry, not following you.  I want this in a html table until I done getting all the additions for the user.  From reading this would be putting into a actual data store table like oracle if Im reading correctly???

so they enter values in basic text fields, click add button and then then those fields create another <TR><TD> ........ structure in the table with the data just entered.  Once their all done, they click submit button and then I have my servlet process table entries and then do the physical add to the database....

<table>
<tr>
  <td>Frank Smith</td>
  <td>2110 S. Willow</td>
  <td>MO</td>
</tr>
</table>
0
 
LVL 9

Expert Comment

by:zkeown
ID: 23661603
No no that's javascript... creates the table right there on the client.
0
 
LVL 5

Author Closing Comment

by:TheVeee
ID: 31547823
Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question