We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Collect data and add to table

Medium Priority
655 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
Comment
Watch Question

Commented:
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 + "\" />";

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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>

Commented:
No no that's javascript... creates the table right there on the client.

Author

Commented:
Thanks!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.