DTP


 
Lively discussions on the graphic arts and publishing — in print or on the web


Go Back   Desktop Publishing Forum > General Discussions > Web Site Building & Maintenance

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 10-10-2013, 04:50 AM   #1
jwoolf09
Member
 
Join Date: Oct 2005
Location: Manchester, NH
Posts: 65
Default A repeating form with PHP and Javascript?

I'm working on teaching myself web-programming using PHP and MySql as the back end. Specifically, I'm working on a database to build and display my website dynamically. Since the goal here is to teach myself web-database programming, and the database I need is much too big to edit through something like HeidiSQL, I'm creating a series of webpages to be front end for adding and editing records in the said database.

Right now, I'm looking at the (seemingly) thorny problem of adding lines to a repeating group in a web form. That is, I have a web form that is a series of repeating groups, each group corresponding to 1 row in a table. I want this one form to be able to both edit existing records and add new records. I'd like to be able to add new lines and populate them, then have the whole form saved as a single Submit operation, old lines and new lines at the same time.

In other words, I want to have a form that shows, say, 4 lines:

row 1 --> field1 field2 field3 field4
row 2 --> field1 field2 field3 field4
row 3 --> field1 field2 field3 field4
row 4 --> field1 field2 field3 field4

and buttons for "Add Line" and "Save". The values for fields 1-4 are retrieved via an SQL query from the table and stored as arrays, then the form lines are generated from those arrays using PHP. Clicking "Add Line" adds a new row to the form, while clicking "Save" submits the whole form, old lines and any new lines, to a second PHP script that saves all rows.

I've tried doing this all in Javascript and run aground on the fact that adding a row to the table apparently doesn't add elements to the underlying arrays. So I get errors when I try to save the new line(s). I can't add elements to the arrays using Javascript, because Javascript doesn't seem to know the arrays exist.

I have a distinct feeling that I'm making this harder than it needs to be ... or that I'm trying to do something that can't be done. Is there a way to do what I want within my form, or am I looking at a problem that can be solved only with asynchronous server calls (which I am not ready to try yet) or by calling the same form with different parameters so that the PHP script handles all the details of adding the new blank line?

-- JSW
jwoolf09 is offline   Reply With Quote
 

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hold the Javascript! john_b Web Site Building & Maintenance 6 02-15-2012 08:17 AM
Eudora 7.1 with Java, JavaScript dthomsen8 Software 14 05-17-2007 01:43 PM
Firefox 1.5 JavaScript Console Kelvyn Web Site Building & Maintenance 0 12-13-2005 11:01 AM
Help with JavaScript coding ilox Web Site Building & Maintenance 15 09-07-2005 12:50 AM


All times are GMT -8. The time now is 09:32 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Contents copyright 2004–2014 Desktop Publishing Forum and its members.