1
Dave_L
Using Javascript to detect when form isn't submitted
  • 2006/5/28 22:47

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I have a form with a textarea and a submit button. Clicking the button saves the textarea contents in the database.

I want to pop up a dialog box if the user changes the contents of the textarea, and then clicks elsewhere on the page without clicking the submit button.

I can partially solve this by adding an OnChange event to the textarea; the event's handler pops up the dialog box as desired.

The only problem is that the dialog pops up if the submit button is clicked. Any ideas on how I can prevent that?

2
bb2120
Re: Using Javascript to detect when form isn
  • 2006/5/28 23:04

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


There's no such function as onunfocus, by any chance? I'm no js expert (as you may alreadu have guessed), but I think that detecting the textarea's focus could be helpful

3
Dave_L
Re: Using Javascript to detect when form isn
  • 2006/5/28 23:13

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


There's an OnBlur event, which is triggered when an element loses focus. But that still doesn't solve the problem.

Also, OnChange is better than OnBlur in this case, since if no change is made to the textarea, there's no need to warn the user to submit the form.

4
bb2120
Re: Using Javascript to detect when form isn
  • 2006/5/28 23:54

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


Sorry, I did not read your post carefully. This is an annoying one. If you get really desperate you could always use flash!

You could code the JS so that it does not pop up when the name/id of the submit button is pressed. I know that this is not proper JS, but it should illustrate my point:

textarea onchange="if([not clicking] document.formname.submit) {
alert('please press submit to save changes')
}" cols="30" rows="30" />

The question is, how do you code the not clicking bit?

5
Dave_L
Re: Using Javascript to detect when form isn
  • 2006/5/29 1:33

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


That's my question.

6
bb2120
Re: Using Javascript to detect when form isn
  • 2006/6/3 22:31

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


Sorry for being an idiot I don't think that it can be done. If you're really desperate you could always use flash!

Login

Who's Online

363 user(s) are online (232 user(s) are browsing Support Forums)


Members: 0


Guests: 363


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits