This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Enable isn't working in script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Enable isn Watch "Enable isn New topic
Author

Enable isn't working in script

K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
I have the following code which uses 2 jsp variables:


I am calling this script with the window.onload event using window.parent.functionName()".


The alerts work and return the proper values via the alerts, but the object wont enable or disable. Any thoughts?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Why window.parent? Is the form on the same page as the script?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
The script I am calling is an application wide script.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Originally posted by K Robert:
The script I am calling is an application wide script.


That has no real meaning. I repeat, is the the script defined in the same page as the form? Or, if by "application wide", you mean that it is implemented in a .js file, is the file included on the same page as the form?
[ January 05, 2006: Message edited by: Bear Bibeault ]
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
I am sorry for the vagueness... The script I am calling is not part of the page the form is on. It is being called from a jsp that is used to provide functionality to the entire application.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

JSP pages are moot at this point. All that matters is the HTML response that is returned to the browser.

We'll need to know what the page hierarchy is before being able to help. The code you show for manipuating form fields must be on the same page as the form for the code to work as written:



Here, document refers to the containing document. If this code is on another page, document will refer to that page's document.
[ January 05, 2006: Message edited by: Bear Bibeault ]
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
Okay, I removed the script and place it in the page is question. I have enableSubmit() being called on the window.onload event at the top of the html page and this is the code:


Now, I get object not found for "document.form.pbRegistration.disabled = true;". Also, if the conditions aren't met, I only get the first alert "Should be disabled" and no the preceding alert. I am sorry, but I cinfused about this...
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
is form the name of your Form?

IS all of the spelling correct?

Eric
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
If the script is in the same page the way to access is

document.FORMNAME.ELEMENTNAME.PROPERTY = VALUE

If it is in a different page then you do the following

parent.FRAMENAME.document.FORMNAME.ELEMENTNAME.PROPERTY = VALUE..

at least this is how i am using it..


Life called,so here I am.<br />Cheers<br />Niki.:-)
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
Yes, the form name is "form". Do you think this will cause problems?
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
Just a thought... Will the window.onload event load before the objects on the page? If so, it's looking for the object before it is rendered and, thus, not an object yet?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
window.onload fires after all of the elements on the page are rendered.

Eric
 
GeeCON Prague 2014
 
subject: Enable isn't working in script