my dog learned polymorphism*
The moose likes Struts and the fly likes help me with this problem.. 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 "help me with this problem.." Watch "help me with this problem.." New topic
Author

help me with this problem..

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124



onclick of button I want the textbox value associated with that button.
if button[0] is clicked I want the hid_text[0].value
if button[1] is clicked I want the hid_text[1].value

how to get the corresponding value?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Whenever you have a form element with a name that includes JavaScript-sensitive characters such as periods and square brackets, you can't use the usual JavaScript notation of "document.myForm.myInput". However, with JavaScript there's always more than one way to do things, so you just have to get a little creative about how to access the object. One way would be to use the getElementsByName method. This method always returns an array, even if there's only one element with that name. Therefore, something like the following would work:

[ March 23, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: help me with this problem..
 
Similar Threads
Struts HTML Lib w/Ajax - Can't get textbox value to Action class
JSP Action Buttons freez after returning from ajax call
Retrieving value from radio buttons using struts tag(Please let me know if my quest is not clear)
Javascript and Struts Indexed Text Boxes
Enabling / disabling forms (Struts)