Hi guys,
got a form which I want to commit to the database on submit. I have collected the data in the form controls and when they push submit I want it to insert the data to the database. Whats the best way to do this??? Should I call another page and do the work there or do it in the same window. If I do it from another page whats the best way to do this?
thanks

))
Quote:
| Originally Posted by antimatter Hi guys,
got a form which I want to commit to the database on submit. I have collected the data in the form controls and when they push submit I want it to insert the data to the database. Whats the best way to do this??? Should I call another page and do the work there or do it in the same window. If I do it from another page whats the best way to do this?
thanks  )) |
I myself like to put all of my database queries all together on a separate page. I place them in functions and then use if then statements with querystrings to call a certain function. But that's just me!

Was this answer helpful ?
Yes No
Doing the processing on the same page or on another page is really up to you. On the same page means you can usually use the same layout and design with minimum changes. You can do this by displaying the form or the result within the content section of your layout and avoid using ASP within the nav. However it also means that you need to keep track of which state the window is pretending to be, whether it is before the submit or after the submit.
Basically if it is a simple job you can probably do it in the one page easy enough.
As for the submission to a database take a look around on google, there will be a million ASP database submission scripts sitting there waiting to be "borrowed". If you want some more specific help let us know what database you would like to use and we'll see what we can do.
Was this answer helpful ?
Yes No
yeah I will do this have yo got a few tips on how to do this, someone suggested the onload event of the body tag ???
Was this answer helpful ?
Yes No
Take a look at this link.
Assuming it is an Access database you should be able to follow this tutorial and get the results you want.
If you want it in a seperate functions script, save the database processing part of the script as a function into a seperate file. Include the file, then call the function from your main script sending any data you have collected from your form.
Here's the link:
http://www.webwizguide.info/asp/tutorials/add_to_database.asp
Good luck with it.
Bejs
If I have been helpful... tilt my scales...
Was this answer helpful ?
Yes No
I've got the form tag looking like this:
<form name="form1" action="#" onsumit="return form_submit()">
function form_submit(){
window.location.href = "processform.asp?mode=<%request.querystring("mode")%>&id= etc...
}
Then in the process page I got server script parsing the querystring doing the database stuff and js on the onload event of the body cleaning up closing the window and refreshing the parent page.
Something aint working do you want me to post my code, or is there something wrong with what I"m doing???
cheers,
Was this answer helpful ?
Yes No
Yeah... paste the code in.
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by bejs Take a look at this link.
Assuming it is an Access database you should be able to follow this tutorial and get the results you want.
If you want it in a seperate functions script, save the database processing part of the script as a function into a seperate file. Include the file, then call the function from your main script sending any data you have collected from your form.
Here's the link:
http://www.webwizguide.info/asp/tutorials/add_to_database.asp
Good luck with it.
Bejs
If I have been helpful... tilt my scales... |
Tanks Bejs I will try js on the same page to do the database stuff.
Was this answer helpful ?
Yes No
Actually....
Where is the form getting "mode" and "id" from? If you are trying to submit mode and ID from the form you should change it to this:
Code:
<form name="form1" action="#" onsumit="return form_submit()">
your action should be set to GET or POST depending on whether you want data sent via the POST method or via the URL. POST is usually better...
If you form elements are named "mode" and "id" then you can do the request.querystring("mode") on the processform.asp page. Use this data and drop it into your database...
hopefully I haven't confused you.... or myself for that matter.
Quote:
| Originally Posted by antimatter I've got the form tag looking like this:
<form name="form1" action="#" onsumit="processform.asp">
function form_submit(){
window.location.href = "processform.asp?mode=<%request.querystring("mode")%>&id= etc...
}
Then in the process page I got server script parsing the querystring doing the database stuff and js on the onload event of the body cleaning up closing the window and refreshing the parent page.
Something aint working do you want me to post my code, or is there something wrong with what I"m doing???
cheers, |
Was this answer helpful ?
Yes No
JS wont be able to do it... JS is a client side language... it cant access the database sitting on your server. You need to use ASP to do it.
edited
-----------
See the link in my submission above
Was this answer helpful ?
Yes No