Thursday, January 21, 2010

Modal Dialog Boxes & Javascript

Modal Dialog Boxes & Javascript
I'm hoping one of you already knows the answer on this. Javascript has "confirm" function that puts up a modal dialog box that gives you the choice of "OK" or "Cancel" and returns true or false accordingly. That's fine for some things--but what you want to change the text to "Yes" or "No" or (let's get really extravagant here), you want to give the user three choices, and have a function that returns 0, 1, or 2?

I know that there must be a way to do this--but darned if I can figure it out. There's certainly a way to do this with the jQuery package, but in the grand tradition of the Internet, trying to find a simple example is pretty much impossible. No, it doesn't need to do fifteenzillion amazing things when you click on the buttons--I just need the ability to control the text for 2 or 3 buttons, and return to the caller a value indicating which button got pushed.

In C#, or Java, this would be trivial.

UPDATE: A reader pointed me to this solution, which looks perfect.

No comments:

Post a Comment