473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Pop up window in ASP

31
Hi,

I would like to define a function in ASP which poped up a window and asking me if I am sure?
something like:

SUB ConfirmDelete()

...popup confirmation window

return (answer)

END SUB


Confirmation=ConfirmDelete()

AND I don't want to use JavaScript. Do you have any idea how should I do it?

Regards,
FF
Jun 11 '08 #1
7 1406
jeffstl
432 Expert 256MB
Just make a link or button open a new window

Expand|Select|Wrap|Line Numbers
  1.  
  2. <a href="mylink.asp" target="_blank">Save</a>
  3.  
  4.  
Then on the mylink.asp page just redirect it to itself after they hit "yes" for sure, and save\delete whatever action, or if its no simply redirect them back to the original page I guess.

If you are trying to trigger this popup from a button click then you may need to change where your form is submitting. You could use the actual submit page as your confirmation page too.
Jun 11 '08 #2
F159753
31
how about if I use Javascript? it is not working yet!

Expand|Select|Wrap|Line Numbers
  1.  
  2. <script LANGUAGE="JavaScript">
  3. <!--
  4. function confirmDelete()
  5. {
  6. var agree=confirm("Are you sure you want to delete The Entire Expense?");
  7. if (agree)
  8.     return true ;
  9. else
  10.     return false ;
  11. }
  12.  
  13. -->
  14. </script>
  15.  
  16. <input type='submit' value='Delete' onClick=location.href='ContractorExpenseDelete.asp';return confirmDelete();>
  17.  
Jun 11 '08 #3
jeffstl
432 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. <script LANGUAGE="JavaScript">
  2. <!--
  3. function confirmDelete()
  4. {
  5. var agree=confirm("Are you sure you want to delete The Entire Expense?");
  6. if (agree)
  7. window.location="http://www.site.com/mypage.asp?confirm=yes"
  8. else
  9. window.location="http://www.site.com/mypage.asp?confirm=no"
  10. }
  11.  
  12. -->
  13. </script>
  14.  
  15. <input type='submit' value='Delete' onClick='return confirmDelete();'>
  16.  
Problem here is which expense are they deleting and how does mypage.asp know which expense to delete? Things you might want to think about.
Jun 11 '08 #4
F159753
31
Perfect, one step ahead:)

the small window now pops up and asking if I am sure ? but when I click "yes" then it doesnt do anything. here is the function I have for it:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <script LANGUAGE="JavaScript">
  3. <!--
  4. function confirmDeleteLine()
  5. {
  6. var agree=confirm("Are you sure you want to delete this line of Expense?");
  7. if (agree)
  8.     {
  9.  
  10.     window.location="ContractorExpenseEditDeleteItem.asp?EIID="&strExpenseItemID;
  11.     return true;
  12.     }
  13. else
  14.     {
  15.     alert("no")
  16.     window.location="ContractorExpenseEdit.asp";
  17.     return false;
  18.     }
  19. }
  20.  
  21. // -->
  22. </script>
  23.  
  24.  
  25.  
  26.  
  27.  
  28. <input type='submit' value='Delete' onClick='return confirmDeleteLine();'>
  29.  
do you know what did I put wrong in JavaScript?

Regards,
FF
Jun 11 '08 #5
jeffstl
432 Expert 256MB
Actually it does do something. It is a javascript error saying strExpenseItemID is undefined.

Which this may be where one of your main misunderstandings are.

ASP code is execute and stored on the web server, javascript runs in the user's browser.

You cannot have a .asp variable passed to a javascript function, because that variable is only "known" on the server.

You have to submit a form to a .asp page to process your delete (passing the strExpenseItemID via the form or a hidden control on the form).

You only want to use the javascript for validation. If you return a true or a false you can keep the form from being submitted and utilize this for your validation of the delete

In other words your form action should be set to ContractorExpenseEditDeleteItem.asp?EIID=<%=strExp enseItemID%>

Then your submit button should call your javascript and return true or false

I believe you will find the below code to work exactly as you expect

Expand|Select|Wrap|Line Numbers
  1. <script LANGUAGE="JavaScript">
  2. <!--
  3. function confirmDeleteLine()
  4. {
  5. var agree=confirm("Are you sure you want to delete this line of Expense?");
  6. if (agree)
  7. {
  8.  
  9. return true;
  10. }
  11. else
  12. {
  13. return false;
  14. }
  15. }
  16.  
  17. // -->
  18. </script>
  19.  
  20.  
  21.  
  22.  
  23. <form action="ContractorExpenseEditDeleteItem.asp?EIID=<%=strExpenseItemID%>" method="post">
  24. <input type='submit' value='Delete' onClick='return confirmDeleteLine();'>
  25. </form>
  26.  
Jun 11 '08 #6
jeffstl
432 Expert 256MB
If you don't know what strExpenseItemID will be then you need to pass it with a hidden form control or something possibly that a user enters or gets filled in on the form from a drop down

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" value="<%=strExpenseItemID%>" name=txtExpense>
  2.  
Something like that or you need to ensure that the expense id is passed in some way from the form.
Jun 11 '08 #7
F159753
31
I put the variable in a Session variable in ASP and it is working perfectly:)

Thank you so much for your help:)

Have a nice day.
Jun 11 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Carol Lyn | last post by:
Could use your assistance with this. I have a window that opens via onclick and it is a small window with info about a site. If the user is interested in visiting that site, there is a link to...
2
by: Juan Garcia | last post by:
Subject says it all. Given: Window A with text field. Window B with a button (onClick opens Window C) Window C with a button (onClick I want it to modify text fields of Window A) I have...
6
by: David Hayes | last post by:
juglesh <juglesh@nospamRadioKDUG.com> wrote in "Re: how to maximize the browser window that fits the monitor size?" (Saturday, January 01, 2005 3:12 AM): > > >I want to maximize the browser...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
4
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database...
5
by: asadhkhan | last post by:
I have the following code which works correctly in IE 6, but in IE 7, Fire Fox 2.0 and Netscape 8 it does not work. I have a main page where a button calls this pop-up and uploads a file once you...
24
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.