Forum Moderators: open

Message Too Old, No Replies

Dynamic creation of form entry rows (Classic ASP + Ajax)

         

Joff

11:52 pm on Mar 14, 2007 (gmt 0)

10+ Year Member



I've got an ongoing project and there's a part of it I'd like to try to solve with Ajax (using Classic ASP) so the browser doesn't need a full on submit.

If anyone could point me in the right direction it would be appreciated.
I'm fine with the db schema and happy to code this outside of the Ajax world but want to push myself a bit where I can.

The project is a reporting system where the item being reported is made up of a number of static fields, eg.

ItemID, Item Name, Item Ref, Date

In addition to the above, the item can have n number of attribute rows, eg.
AttributeID, Name, Qty, Description

The Ajax part I'm looking for would be to create/update the attributes.
By default, the Item is created with zero attributes and will display the user with a single blank form row to enter an attribute.
On submitting, the attribute is committed to the DB and another blank form row is provided should the user wish to add more attributes.

I've hacked about with an Ajax search autocomplete form in the past with some success so I've got something to start on re. sample code for XML HTTP Request, but just can't get my head around where to begin with this one.

Apologies for the lengthy explanation, hopefully you can get the gist of what I'm aiming to achieve.

RonPK

11:54 am on Mar 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd start with a simple form, with a button that
onclick
calls the javascript that builds the sendstring for the request and sends it to the ASP script.

If the ASP script replies with 'OK', start building the new form row. It's probably best to do that using DOM methods, such as

createElement()
and
appendChild()
. Simply adding html to some container's
innerHTML
often doesn't work, especially with forms.

Let us know if you need more details.