473,607 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with confirm box in javascript

118 New Member
Hi,


I want to applying the styles for confirm box. For this purpose i have used below code.

Here i am writting my code
Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  2. <head>
  3. <title>untitled</title>
  4. <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
  5. <script type="text/javascript">
  6. function doConfirm(v)
  7. {
  8. var b = document.getElementById('btn');
  9. b.value = 'Display dialog [last return value: ' + v + '/' + (v ? 'OK' : 'Cancel') + ']';
  10. }
  11.  
  12. function setDisp(id, disp, some)
  13. {
  14. document.getElementById(id).style.display = disp;
  15. return some;
  16. }
  17. </script>
  18. <style type="text/css">
  19. #confirm {
  20. position: absolute;
  21. top: 40px;
  22. left: 70px;
  23. border: outset #000 10px;
  24. padding: 1em 3em;
  25. display: none;
  26. background: #a5c4cc;
  27. }
  28.  
  29. #ok {
  30. background: #a5cca8;
  31. }
  32.  
  33. #cancel {
  34. background: #d6a4a4;
  35. }
  36.  
  37. #ok, #cancel {
  38. padding: 2px;
  39. margin:2px;
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. <div id="confirm">
  45. <div><strong>Are</strong> <em>you</em> <span style="text-decoration: underline;">sure</span>?</div>
  46. <input type="button" id="ok" value="OK" onClick="setDisp('confirm', 'none','yes');" />
  47. <input type="button" id="cancel" value="Cancel" onClick="setDisp('confirm', 'none','no');" />
  48. </div>
  49. <input type="button" id="btn" value="Display dialog" onClick="setDisp('confirm', 'block','');" />
  50. </body>
  51. </html>
  52.  
  53.  

In above code i have to set return value to the function setDisp() as true/false when click on ok ,cancel buttons. That means when i used the function setDisp() directly then it displayed the pop up window consists the ok,Cancel buttons.When i click on ok this function setDisp() returns true and when click on cancel this function setDisp() returns false. That is my requirement .Any body could you please help me how can get the Requirement.



Thanks
Swetha
Jul 29 '09 #1
3 3140
paulrajj
47 New Member
try something like this in your javascript code
Expand|Select|Wrap|Line Numbers
  1. function setDisp(id, disp, some)
  2. {
  3.  
  4. document.getElementById(id).style.display = disp;
  5. if(some != '') 
  6. {
  7.     doConfirm(some); 
  8. }
  9. return some;
  10.  
  11. }
  12.  
Jul 29 '09 #2
swethak
118 New Member
Hi,



I tried like this .But i am not getting. please advice me.









Thanks
Sravani
Jul 30 '09 #3
paulrajj
47 New Member
hi,

just make a little change in doConfirm function then try it out. It works fine in both IE and FF.
Expand|Select|Wrap|Line Numbers
  1. function doConfirm(v)
  2. {
  3. var b = document.getElementById('btn');
  4. (v == 'yes') ? z = 'OK' : z = 'Cancel';
  5. b.value = 'Display dialog [last return value: ' + v + '/' + (z) + ']';
Jul 31 '09 #4

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

Similar topics

1
2643
by: Muhammad Abdullah | last post by:
Hi am having some problems with the javascript confirm. i have it working fine on one page and it doesnt even pop up at the other. The code on the working page is, private void Page_Load(object sender, System.EventArgs e) { if(! Page.IsPostBack)
7
3106
by: Grey | last post by:
how to design confirm message box, like Javascript Confirm box, in ASP.NET?? if the user click "YES" in the confirm box, i need to do something, else do other things. Do I need to have javascript confirm box or ASP.NET has such feature?? Million thanks.
13
5653
by: Chris | last post by:
I can create Javascript confirm message boxes during page creation, etc adding them to the button attributes (many good posts on this!). But how can I add this event after the button is pressed? I have created an Is_Dirty routine checking for field changes on my page then if the user clicks on the "exit" button I check for Is_Dirty = true and want to ask then "do you want to exit without saving?". It's a code behind where if the value of...
3
2401
by: Tarun Upadhyaya | last post by:
Hi, I am facing strange problem I read Scott mitchell's article about ASP.NET and javascript at http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/clientsidescript.asp where he has talked about creating a base class for displaying alerts and confirms after and before postbacks respectively. I used that Base class to inherit on of my code behind classes and and i
5
2589
by: comshiva | last post by:
Hi all, I have converted my existing ASP.NET project from 1.1 to 2.0 and i have found that everything works fine except the linkbutton control in my datagrid which throws an javascript error when clicked. I thought the control might be the problem, so i deleted the old control and binded the new linkbutton control but am still getting the same error. Am using visual studio 2005. Source code inside my grid:...
1
1441
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my database has been made in MSDE. I have a DataGrid, and have inserted a delete link button into it through Property Builder. My Delete method works fine, however I would like to insert a JScript popup to confirm, as otherwise users can just
7
1767
by: Trickynick1001 | last post by:
Hi, a newbie here. I don't have a real firm grasp on the idea of Javascript, as I'm used to programming in Qbasic and C. I'm not used to OOP. Anyway, I really don't have any idea what the problem is with this code, it just simply won't work properly. Some of the functions aren't done, but the main one gives me a Not a Number message in the text box where the calculations are supposed to come up. I tried to use a parseInt on my stuff,...
5
1130
by: phil | last post by:
Hi, Is this a javascript or asp.net problem? When the button is clicked, the server event in the code-behind must be executed if the user clicked on "OK" of the Confirm and not executed if clicked on "Cancel". I tried two ways: the first here below works perfect but the second way ALWAYS executes the server event!! Can anybody explain me why? Thanks
4
10019
by: tfsmag | last post by:
Okay, I have a project management app i'm writing and in the left hand menu i have a treeview control that is populated with each project... in child nodes under each project node I have an "edit" and a "delete" node. I have the functionality of the edit and delete working fine, my issue is now however that I cannot seem to find a way to add an "onclick" event that fires a confirm box. I've tried this method.. treenode.Text = "<a...
0
7987
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8472
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8324
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3954
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2464
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1318
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.