SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: Prompt Help

  1. #1
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Prompt Help

    Is there any way to make a prompt window show a choice between Yes and No instead of Ok and Cancel?
    SK

  2. #2
    SitePoint Guru momos's Avatar
    Join Date
    Apr 2004
    Location
    Belgium
    Posts
    919
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the "confirm" function does such a thing, but only works in IE as far as I know

  3. #3
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The method confirm() works in all major browsers and you can NOT change the value of the buttons. The values are taken from the browser so if the user has installed swedish version of the browser it should say "OK" and "Avbryt" instead.

  4. #4
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does confirm show yes and no?
    SK

  5. #5
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by andrin
    ... and you can NOT change the value of the buttons. The values are taken from the browser...
    .

  6. #6
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Eek... thanks for the help andrin!
    SK

  7. #7
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not make your own?

  8. #8
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make my own what?
    SK

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    </
    head>

    <
    body>
    <
    div id=myprompt style="position:absolute;z-index:10;visibility:hidden;top:0px;left:0px;width:480px;height:125px;background-color:#D8D0C8;font-family:arial;border-right:solid gray 2px;border-bottom:solid gray 2px;border-left:solid #E6E6E6 2px;border-top:solid #E6E6E6 2px;" >
     <
    div style="position:absolute;top:2px;left:2px;width:476px;height:20px;background-color:#5878B0;color:white;font-size:12px;font-weight:bold;font-family:arial;" >
     <
    div style="position:absolute;top:2px;left:10px;font-size:12px;font-weight:bold;font-family:arial;" >My Prompt</div>
     </
    div>
     <
    input type="button" name="" value="X"
      
    style="position:absolute;overflow:hidden;top:3px;left:455px;width:18px;height:18px;font-size:12px;font-weight:bold;"
      
    onclick="javascript:MyPromptEnter(ip);"
     
    >
     <
    div style="position:absolute;top:30px;left:5px;width:200px;height:15px;font-size:12px;" >Script Promp:</div>
     <
    div id=mypromptTxt style="position:absolute;top:55px;left:5px;width:370px;height:50px;font-size:12px;" ></div>
     <
    input type="button" name="" value="Yes"
      
    style="position:absolute;top:30px;left:390px;width:80px;height:25px;"
      
    onclick="javascript:MyPromptEnter(1);"
     
    >
     <
    input type="button" name="" value="No"
      
    style="position:absolute;font-size:10px;top:60px;left:390px;width:80px;height:25px;"
      
    onclick="javascript:MyPromptEnter();"
     
    >
     <
    input id=mypromptIP size="20" value="undefined" style="position:absolute;top:90px;left:5px;width:465px;height:16px;" >
    </
    div>


    <
    br>
    <
    br>
    <
    br>

    <
    input type="button" name="" value="MY PROMPT" onclick="MyPrompt('This the text for my prompt','AnyFunction()');" >

     <
    script language="JavaScript" type="text/javascript">
     <!--

     var 
    MyPrompObj=document.getElementById('myprompt').style;
     var 
    MyPrompTxt=document.getElementById('mypromptTxt');
     var 
    MyPrompIP=document.getElementById('mypromptIP');

     function 
    MyPrompt(mess,funct){
      
    MyPrompFunct=funct;
      
    MyPrompIP.value='undefined';
      
    MyPrompTxt.innerHTML=mess;
      
    MyPrompObj.visibility='visible';
     }

     function 
    MyPromptEnter(ip){
      
    MyPrompObj.visibility='hidden';
      
    MyPrompVar=null;
      if (
    ip){
       
    MyPrompVar=MyPrompIP.value;
       eval(
    MyPrompFunct);
      }
     }

     function 
    AnyFunction(){
      
    alert('MyPromptVar = '+MyPrompVar);
     }
     
    //-->
     
    </script>

    </body>

    </html> 

  10. #10
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great code (I found it!!)

    One small suggestion - if you use cursorointer on the buttons, it looks a little more professional.

    cheers

    monkey
    monkey - the rest is history


Bookmarks

Posting Permissions

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