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

javascript code for Msgbox("Save before Exit",vbYesNo)

Status
Not open for further replies.

mb22

Programmer
Sep 4, 2002
258
US
Please help with Javascrip code to implement a Yes/No response from a Msgbox. Either case I still want to submit the form but do different processing depending on the answer.
(Confrim does NOT submit when you select Cancel, and Alert has only OK). Do I perhaps need a hidden field to store a value for the answer .. and then use a Case/Switch? I am newbie to Javascript.... please help with javascript code!!!!



If MsgBox("Save before Exit?",vbYesNo)="Yes" then
SaveRecord()
RetrieveNextRecord()
else
RetrieveNextRecord()
end if


Mikey
 
if(!confirm(Save before Exit?'))
{
SaveRecord()
RetrieveNextRecord();
}
else
{
RetrieveNextRecord();
}

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Actually, I think Tracey meant this:

if(confirm(Save before Exit?'))
{
SaveRecord()
RetrieveNextRecord();
}
else
{
RetrieveNextRecord();
}

The way Tracey had it, it would save the record if the user pressed Cancel and not save it if the user pressed OK.
 
Oooops....

The first line should read:

if(confirm('Save before Exit?'))
 
oh yes cheers cglinn, i forgot to remove it after pasting ... duh-oh

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Thanks ..... but

SaveRecord()
RetrieveNextRecord()

are both Subs or functions in my code-behind file (myform.codebehind.vb) say! Will client side script be able to call these functions? I thought the code-behind file is not available to the client, it only remains on the server!

Or will this automatically SUBMIT the form in BOTH situations ... whether you answer "Yes" or "No" ? Hmm by the way will it be Yes/No or OK/Cancel? I want it to be Yes/No since I want to take action regardless of the answer.

Cheers

 
Yes/No will be the display buttons

I really dont know much about vb. I work with Delphi cgi/isapi

Are you using asp?

I would do something like:
Code:
if(confirm('Save?'))
  {
     window.location='[URL unfurl="true"]http://pathToApplication/appname.asp/saveandmove?save=yes[/URL]
   }
   else
   {   window.location='[URL unfurl="true"]http://pathToApplication/appname.asp/saveandmove?save=no[/URL]
   }

If that were the case, or I may be totally off on what you are doing...






Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Thank you Tracey .. that worked!

Is there a way to code the "Confirm" funtion to display a Yes/No combination ... instead of OK/Cancel which is the default?

Thanks again anyway!
 
oh sorry mb, got that one wrong. I dont think you can, from memory.

Tracey
Remember... True happiness is not getting what you want...

Its wanting what you have got!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top