[Javascript] posting multi-record forms

Matthew Pearce mpearce at digitas.com
Fri May 3 11:43:44 CDT 2002


Using http post, I want to handle a form with multiple records.

The client requests a page from the server with contains the following information

	id   title     flag1     flag2
	id   title     flag1     flag2
	id   title     flag1     flag2
	.. etc ..

The title is visible in the page as text and the flags are shown as checkboxes (either checked or unchecked). The id does not need to be visible, however it represents a database id, and needs to be sent back to the server. The ids are not sequential. Each record represents a different news article.

I want to do something ever so simple which is to allow the flag elements to be changed on the client end, and then the form will be posted to the server.

I would like to do the minimum of processing on the server side when this posted data is received. Therefore if 200 articles are sent to the client, but only one flag is changed, I don't want to send 200.x strings back to the server, I just want to send:
i)  one id and 
ii) identify which flag has changed and 
iii) what value it has changed to.

The only workable solution I can think of is to use posted data like:

 id20_flag1=true&id20_flag2=false

and then, on the server side,  scan the strings in the entity body with an indexOf style statement.

Does anybody have any suggestion of how, using javascript on the client side, I can send "just enough and no more" information back to the server.

Is there an established pattern for this.

Matt Pearce




More information about the Javascript mailing list