• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JavaScript - Enable Submit Button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JavaScript - Enable Submit Button


  • Subject: Re: JavaScript - Enable Submit Button
  • From: Michael Engelhart <email@hidden>
  • Date: Sun, 22 Aug 2004 11:09:53 -0500

Hi Erwin -

Well I'm not exactly an expert but in your case you were setting the 'disabled' property of the submit button to false and the way the javascript works is that the last executed command is evaluated and returned to the handler which in this example evaluates to "false" so basically whatever the onChange method of a text field would normally do is halted because you returned false. HTML form event handler returns true or false (by evaluating the last command if no return value is explicitly returned). Returning true allows the event to do what it was going to do had you not trapped the event so you should usually return true unless you're doing form checking or something where you don't want say the Submit button to post the form for example.

As for Javascript info, O'Reilly's Javascrtipt: the Definitive Guide is really good but it's 900 pages so it's not exactly a pocket reference.

On an semi-related note, my useful javascript tidbit of the day I just learned is that the <img> tag ((and other tags too) in a page has an "onerror" handler. This is called when the image you're trying to download is corrupt or nonexistent. This is extremely useful in situations where you may not know if an image exists and you want to display a single pixel gif it's not available.

So for example in a page you can have something like this;
<img src="/images/somefile.gif" width="100" height="100" onerror="this.src='/images/blank.gif'" />


and if the somefile.gif doesn't load, the blank gif goes in it's place. The way this works in a WOImage file is simply to add this to your .wod:

MyImage: WOImage {
   	src = getMyImage;
	width = "64";
	height = "64";
	border = "0";
	onerror = "this.src = '/images/blank.gif'"
}

Probably more then you wanted to know...  :-)

Cheers
Michael

On Aug 22, 2004, at 10:00 AM, Erwin wrote:

Thanks it works...
I am not a JavaScript specialist... what is the trick with the return value (false or true)
where can I find useful info on using return values... from JS ?


I tried another design, with a disabled Checkbox (save the form data) inside the Form
and using the same onChange string...
the Checkbox becomes enabled, so I can check it.... but when I submit the Form, I got an unchecked value ...
fortunatly the first design works... thanks


rwin

Le Aug 22, 2004, ` 3:08 PM, Michael Engelhart a icrit :

Try this:
onchange   "this.form.savebutton.disabled= false; return true;"

Mike
On Aug 22, 2004, at 3:30 AM, Erwin wrote:

I would like to enable/disabled a 'Save Form Data' button if anyone text fields changed before submitting the form.

I selected 'multiple submit = true' in my form and I inserted 2 dynamic submit buttons 'Save' and 'Submit'
I binded the 2 buttons to 2 actions 'saveData' and 'submitForm'
The 'Save' button is initially disabled


I am enabling the Save button using a JavaScript string in all my textfields
-> onChange "this.form.savebutton.disabled= false;"


Running, when I modifiy one of the textfields, the Save button is enabled ... good
but I never get into the saveData action...... _______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >JavaScript - Enable Submit Button (From: Erwin <email@hidden>)
 >Re: JavaScript - Enable Submit Button (From: Michael Engelhart <email@hidden>)

  • Prev by Date: Re: inter-instance communication
  • Next by Date: Re: Just once more, an EOF/ObjC replacement?
  • Previous by thread: Re: JavaScript - Enable Submit Button
  • Next by thread: How WO compare with JDeveloper
  • Index(es):
    • Date
    • Thread