SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello All,
    In javascript I am able to use 2 commands
    alert and confirm.
    But alert appears with OK button and confirm appears with OK/Cancel button. But What I need is to show Yes/No button. When they say Yes they will stay in the same page, otherwise they will be forwarded to another page
    Is it possible in Javascript or are there any other way then JavaScript?
    Thx

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm afraid you can't display a Yes/No dialog with JavaScript. You'll need to reword your user prompt so that it makes sense for OK/Cancel (e.g. "Click OK to be forwarded, or CANCEL to stay here.").
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    SitePoint Addict Drinky's Avatar
    Join Date
    Jan 2001
    Location
    England
    Posts
    338
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could learn some DHTML and make your own.
    Drinky

  4. #4
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Eek! I wish you could just use VBScript. It's soooo easy when you do it that way. but nope, VBScript isn't cross-browser compatible...grrr...
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  5. #5
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    edited to heckle Kyank ;)

    Found it! This will pop up a cancel button...
    Code:
    <SCRIPT LANGAUAGE="javascript">
    function gocancle()
    {
    if (confirm("Are you sure you want to enter HTML Goodies?") )
    {
    window.open('http://www.htmlgoodies.com','htmlgood');
    alert("Good choice");
    }
    
    else
    {
    alert("Then you'll stay right here");
    window.status='Chicken!';
    }
    }
    </SCRIPT>
    Basically, what this code does is:
    1. Uses the confirm() function to display an okay / cancel box
    2. uses the if statement to see whether the clicked okay or cancel
    3. If the user clicked okay, the page opens a window and displays a message box.
    4. If the user clicks cancel, it displays a message in a message box and then in the status bar.
    This should be easy enough to figure out with the explanation. Any questions? I'm just a click away.

    Hope this helps. Kevin, I guess you can do an okay / cancel dialog in JS.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  6. #6
    Irritability Defined
    Join Date
    Jul 2000
    Location
    80,000 feet below the surface
    Posts
    1,442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Smells like another tip for the Tech Times Kevin!
    My 2 Cents (or is that 2.2 Cents including GST?)

  7. #7
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooh, really? if you could say my name in there....wow..that's just awesome! I'd print it and frame it.

    "My contribution to the Technical world."
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  8. #8
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    <shakes head> You should read the question before heckling, goober. Quoting the original message in this thread:

    In javascript I am able to use 2 commands
    alert and confirm.
    But alert appears with OK button and confirm appears with OK/Cancel button. But What I need is to show Yes/No button.
    As I said, you're stuck using confirm() (OK/Cancel) -- there is no way to make a YES/NO dialog.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  9. #9
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DOH!

    My apologies, Kevin.

    Foot and Mouth -- The perfect fit when it comes to me, sorry to say.

    Yes, you are stuck using OK / Cancel. There HAS to be a way to have a yes / no script! I will go digging. Likely to come up empty, but still digging...

    Sorry again, Kevin. I know you're good-natured enough to forgive me.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  10. #10
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    There is a way to do it in MSIE only, which allows you to design custom dialogs using VBScript. There's plenty of info on MSDN. Browser compatibility is too great a sacrifice just for changing the labels of two buttons.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  11. #11
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Current solution is
    Click on OK if .....
    Click on Cancel if ....
    thx for your replies


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
  •