Jump to content

Suggestion on how to handle dynamic table data


TheValidator
 Share

Recommended Posts

Hi All,Looking for suggestions on how to proceed with the following......On main.html, there is a form with multiple inputs, one of which asks for "how many datapoints". The form's action is to a page called maketable.asp. On maketable.asp, a table is constructed whose number of rows corresponds to the number of datapoints entered on the main.html page. I now need to transfer the data entered in the table on the maketable.asp page into a SQL Server DB.My 2 questions are:1. Is there a way to save or store the "number of datapoints". It appears that once the value is transferred to the maketable.asp page, it is gone.2. What is the technique to enter the table data into SQL Server DB? Since the data table on maketable.asp will have a variable number of rows, I need a means to handle that and I'm stumped at that point.I hope I am clear and thank you in advance.

Link to comment
Share on other sites

You can use a hidden input to store values like the number of rows. The hidden inputs will get submitted with the form, but they don't show up in the browser. For the database, there are tutorials on the w3schools site that show connecting to a database and sending queries. You can use the number of rows to loop through the form data and send each row to the database.

Link to comment
Share on other sites

You can use a hidden input to store values like the number of rows. The hidden inputs will get submitted with the form, but they don't show up in the browser. For the database, there are tutorials on the w3schools site that show connecting to a database and sending queries. You can use the number of rows to loop through the form data and send each row to the database.
Thanks for the suggestions.The hidden fields did the trick to carry over the values.I have to work on the transfer of data from the form to the DB. It's not so much the code to do the actual transfer. It is more how to handle the variable amounts and multiple fields. The table of data is being dynamically generated using ASP code. So the table's first row of fields (time, temp, date) have the same names as the fields in the second row (also called time, temp and date). Now that I can carry the number of rows into the maketable.asp page, I can construct a loop. But I am puzzled as to how the naming of the fields will work as they are passed to the SQL database.If you have a suggestion for this one, I'd appreciate it and I'll definitely keep working on it.thanks again.
Link to comment
Share on other sites

The fields need different names. The code to print the table should append a number onto the names, and you should do the same when you get the values. e.g. time1, temp1, date1, time2, temp2, etc.
PERFECT !I included the variable loop counter into the name as you suggested....works perfectly.Can't wait to see what other hurdles await.THANK YOU.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...