Forums

ASP

This topic is locked

Insert and Delete help please

Posted 06 Sep 2005 16:39:26
1
has voted
06 Sep 2005 16:39:26 billy jones posted:
I have a .asp page with a recordset showing results from an access table called "pending_resources". I have a submit button which when clicked inserts the shown record (6 fields) into an identical table called "online_resources".

When I click the submit button I want the record from "pending_resources" to be deleted, but Dreamweaver wont let me put an insert and delete behaviour in the same form.

Is they a way I can get an automatic delete from "pending_resources" after update to "online_resources"?

Replies

Replied 06 Sep 2005 17:34:49
06 Sep 2005 17:34:49 Michael Behan replied:
you could do this using a trigger in the database (FOR INSERT DELETE FROM), or you could make a form on another page with a delete record behaviour. When the insert is complete you redirect to this page where the form fields take their defaults from the previous form, make the form submit onLoad and when the delete is complete redirect to whatever page you currently want to see after the insert (so no-one ever sees that the delete took place on a different page!)

I would reccomend the trigger option, but the other way will work!
Replied 06 Sep 2005 17:50:24
06 Sep 2005 17:50:24 billy jones replied:
Ok how do I get a form to run a delete through an page onload event?
Replied 06 Sep 2005 19:11:17
06 Sep 2005 19:11:17 Michael Behan replied:
in the body tag

onLoad="document.nameOfForm.submit();"

where nameOfForm is the name of the form!
Replied 06 Sep 2005 19:32:58
06 Sep 2005 19:32:58 Michael Behan replied:
(using a regular dreamweaver delete record behaviour)
Replied 06 Sep 2005 23:45:48
06 Sep 2005 23:45:48 billy jones replied:
Many thanks for your help!! I just want to make sure im getting it correctly...

The page I want to automatically run the delete is called "pending_resources.asp", and the form on this page is called "pending_resources_form".

When I click the submit button on this page I want it to take me to the delete page which will automatically delete the pending_resources - called "delete_pending_resources.asp". The form on "delete_pening_resources.asp" is called "delete_pending_resources_form".

Have I got the following code right -
onLoad="pending_resources.asp.delete_pending_resources_form.submit();"
Do I put this code in pending_resources.asp or delete_pending_resources.asp





Edited by - moss2076 on 07 Sep 2005 00:36:30

Edited by - moss2076 on 07 Sep 2005 00:38:40
Replied 07 Sep 2005 11:25:17
07 Sep 2005 11:25:17 Michael Behan replied:
on the pending_resources.asp page, open the insert record behaviour's options dialog box and type "delete_pending_resources.asp" in the "after insert go to" field.

on the delete_pending_resources.asp page you put the onLoad bit, which should look like this: (don't replace document with the name of the document) onLoad="document.pending_resources_form.submit()"

Edited by - mbisme on 07 Sep 2005 11:28:34
Replied 08 Sep 2005 18:43:20
08 Sep 2005 18:43:20 billy jones replied:
Thats got it sorted <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> Many Many thanks for your help, you are a genius!!

Reply to this topic