This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Enabling / disabling forms (Struts) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Enabling / disabling forms (Struts)" Watch "Enabling / disabling forms (Struts)" New topic
Author

Enabling / disabling forms (Struts)

Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Howdy.

If I've got the following:



How could I have it so that "fName" is disabled when the value of gender is "male"?

[edited to disable smilies -JM]
[ June 01, 2004: Message edited by: Jason Menard ]
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

You're asking for the page to change when the user clicks a radio button. You will need javascript to do this.


A good workman is known by his tools.
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Alright, I'll give that a try, thanks.

Any particular URLs you can recommend? I've tried alot of the javascript I've seen on the web and haven't had much success.

A site that has javascript that works with Struts would, of course, be preferential.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Does this work?



In addition, I dont think the name attribute is needed, as the tag can be identified by the property attribute.

I think JavaScript for Struts or non-Struts tag is the same, but just the tag attribute name differ, you may check out how to use JavaScript attributes from:
http://jakarta.apache.org/struts/userGuide/struts-html.html

Nick
[ June 01, 2004: Message edited by: Nicholas Cheung ]

SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Works like a charm Nick (minus the space between "on click"), thanks alot.
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Hmm... something new has come up that I think is well beyond me.

When I create my .jsp I pre-populate the forms with values from a bean.



That works fine, as does the second_enabled script.

The problem comes when I try to determine, on start up, if the value of "interval" is "weekly" or "biweekly".



This doesn't work. The document.write("I was called "); never shows up.

What makes things odd (for me at least) is that if I change the code to the following:



The document.write("I was called "); now shows up.

I can't imagine why this would be. The only difference between the two is that custID is an integer within the populating DTO and interval is a String.

Both properties do have values within the bean.

Any have any idea why this is?

(on|oad == onload, the forum doesn't seem to like that word)

Edit: semi-colons were appearing in places that aren't in my actual document.
[ June 02, 2004: Message edited by: Karl Beowulph ]
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
I changed "interval" to an integer and now it works.

No explanation for how or why though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enabling / disabling forms (Struts)
 
Similar Threads
Cannot retrieve mapping for action
I need a simple drop down list of numbers
change font size in struts
HTML:SELECT
Datasources Problem-Servlet action is not available