Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with Confirm box

    Hi,


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

    Here i am writting my code
    Code:
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>untitled</title>
    <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
    <script type="text/javascript">
    function doConfirm(v)
    {
    var b = document.getElementById('btn');
    b.value = 'Display dialog [last return value: ' + v + '/' + (v ? 'OK' : 'Cancel') + ']';
    }
    
    function setDisp(id, disp, some)
    {
    document.getElementById(id).style.display = disp;
    return some;
    }
    </script>
    <style type="text/css">
    #confirm {
    position: absolute;
    top: 40px;
    left: 70px;
    border: outset #000 10px;
    padding: 1em 3em;
    display: none;
    background: #a5c4cc;
    }
    
    #ok {
    background: #a5cca8;
    }
    
    #cancel {
    background: #d6a4a4;
    }
    
    #ok, #cancel {
    padding: 2px;
    margin:2px;
    }
    </style>
    </head>
    <body>
    <div id="confirm">
    <div><strong>Are</strong> <em>you</em> <span style="text-decoration: underline;">sure</span>?</div>
    <input type="button" id="ok" value="OK" onClick="setDisp('confirm', 'none','yes');" />
    <input type="button" id="cancel" value="Cancel" onClick="setDisp('confirm', 'none','no');" />
    </div>
    <input type="button" id="btn" value="Display dialog" onClick="setDisp('confirm', 'block','');" />
    </body>
    </html>

    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,140
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Well, just change yes and no to true and false.

    <input type="button" id="ok" value="OK" onClick="setDisp('confirm', 'none','true');" />
    <input type="button" id="cancel" value="Cancel" onClick="setDisp('confirm', 'none','false');" />


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •