Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to submit and redirect at the same time

Status
Not open for further replies.

williadn48

Programmer
Oct 27, 2006
29
US
When the user clicks Stop I want to write to the database with a submit AND redirect to a different page. I have tried various combos of code and nothing is working.
function fncStop(){

frmTIMETRACKING.hdnAction.value = 'Stop';

frmTIMETRACKING.submit();
window.location = 'TaskLogged.asp';}
<FORM action="ECM-Time-Tracking.asp" method=post id=frmTIMETRACKING name=frmTIMETRACKING onSubmit="return fncStop()">



 
Why don't you make clicking on the Stop button submit the form, where the action on the form is the redirected page?

At the top of the redirected page, write the information submitted via form to the database.

If you don't understand what I'm saying and are curious about, please feel free to ask.



[monkey][snake] <.
 
To follow up on what monksnake is saying, you cannot do what you need on the client-side (which is what you appear to be doing with the code you provided). To write to the database will require you to access the server (which happens before you ever see the client-side stuff on the browser) - you cannot attempt to write something to the database using client-side code (as you say you're trying to do). You would do well to follow monksnake's advice and simply have your function reset the action property of your form tag to the page where you want it redirected and then, on that page, perform your write/update to the database using ASP. If you have additional questions as to how to do this, post back with specific questions.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top