Joe Levi:
a cross-discipline, multi-dimensional problem solver who thinks outside the box – but within reality™

JavaScript Frustration

I’m a web developer by hobby (and soon to be by profession, again), JavaScript is arguably the most common, easiest, and simplest “quick and dirty” way to make your web pages dynamic.

So, let’s say you want to modify your form’s “Reset” button from its default behavior, and add a dialog that basically says “Are you sure you want to clear your form and start over?” Well, that’s easy enough, right?
var return_value = confirm(“Are you sure you want to clear your form and start over?”); The return values are easily handled: true or false.

But the buttons… [ OK ] [ CANCEL ]. That’s not what I asked! My answers should be [ Yes ] [ No ], shouldn’t they?

Well, you’re asking a CONFIRMation type question, and sometimes YES/NO, RIGHT/WRONG, MORE/LESS, UP/DOWN, NEXT/PREVIOUS are the answers that would best fit your question, but how do you modify the buttons of the CONFIRM() function? Simply, you can’t.

So what are our options? Well, VBscript (and to an extent Jscript) will let you do this, but those are only a MSIE solution. You spawn a popup (and have to deal with popup blockers and properly passing values between browser windows). You could unhide a hidden [div] containing the CONFIRM question and answers in a layer with a higher z-index. Hey, why not make an interim page storing all your submit data between full-browser pages? The most creative solution I’ve seen was a professor at Weber State University who quickly compiled a Japplet and used it to pass parameters from the html form to the applet to the JavaScript.

:: Sigh ::

Anyone have any more elegant (client-side) solutions?

Share

You may also like...

Leave a Reply