JavaScript Frustration

October 26th, 2005 by Joe

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?

Posted in Experimentation, Freelance, Internet, Joe, technology, work

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About Greener Living thru Technology

JoeLevi.com is the personal web log of Joe Levi -- an ASP.NET Web Developer by trade and by hobby. Joe's love of technology isn't just limited to the web, he's also interested in green and environmentally friendly technology and technological solutions. If it has to do with technology, improving the quality of life, geek humor, tech politics, self-defense, environmental stewardship, or anything related, you'll probably find it at www.JoeLevi.com.

Site statistics:
Average: ~1.3 P/V; Visits: ~3,000; Pageviews: ~3,600; Google PR: 4; TechnoratiAuthority: 17; Technorati Rank: 487,964