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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Box 1

Status
Not open for further replies.

pbellc

Programmer
Jun 6, 2003
36
US
I am using an Data Access page created using MS Access to access data in a database (that's alot of Accesses). I'd like to utilize a message box to alert users that they have saved changes to the database before they leave the page. Access uses javascript to save the data. I know how to create a message box using VBscript, but am unfamiliar with javascript. Is there a javascript that will run a function to run a message box when a command button is run to do this? Preferably I would like the message box to open up and give the user the option to "Yes" save changes (upon clicking they would return to the main page, or "No" don't save chages (upon clicking they would return to the form page).

I hope I am being explicit enough. Thanks for any suggestions.

pc
 
function Confrm()
{
if(confirm("Do you want to save the changes"))
{
//user has clicked yes
}
else
{
//user has clicked no.
}
}

in ur button
<input typer=&quot;button&quot;.... onclick=&quot;Confrm()&quot;>


Known is handfull, Unknown is worldfull
 
That works great. The only problem is I am having trouble if figuring out how to get the user back to the main page (say its url is just main.htm). Here is the script I have, can you tell me where and how to enter the redirect link? I know this is probably pretty basic, but I am very new with using javascript. Thanks again.

pc

<INPUT id=button1 style=&quot;LEFT: 1.792in; WIDTH: 2.146in; POSITION: absolute; TOP: 0.083in; HEIGHT: 0.24in&quot; onclick=Confrm() type=button value=&quot;Save Changes to Record&quot; name=button1>
<SCRIPT language=javascript>
function Confrm()
{
if(confirm(&quot;Do you want to save the changes&quot;))
{
//user has clicked yes
MSODSC.CurrentSection.DataPage.Save();
}
else
{
//user has clicked no.
}
}
</SCRIPT>
 
change your Confirm fucntion to...

<SCRIPT language=javascript>
function Confrm()
{
if(confirm(&quot;Do you want to save the changes&quot;))
{
//user has clicked yes
MSODSC.CurrentSection.DataPage.Save();
window.location.href=&quot;main.htm&quot;
}
else
{
window.location.href=&quot;form.htm&quot;
}
}
</SCRIPT>

on error goto hell
 
yep. hope u got the idea...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top