473,320 Members | 1,719 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,320 software developers and data experts.

Problem with confirm box in javascript

118 100+
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 3127
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 100+
Hi,



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









Thanks
Sravani
Jul 30 '09 #3
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
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...
7
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...
13
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...
3
by: Tarun Upadhyaya | last post by:
Hi, I am facing strange problem I read Scott mitchell's article about ASP.NET and javascript at ...
5
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...
1
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...
7
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...
5
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...
4
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"...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.