File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes how to pass form bean value to javascript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to pass form bean value to javascript function" Watch "how to pass form bean value to javascript function" New topic
Author

how to pass form bean value to javascript function

preethi venkatarangan
Greenhorn

Joined: Jan 21, 2007
Posts: 27
I have a textfield created using html:text.
html:text name="nameform" property="formbean.name"
now on blur i want to send this formbean value dynamically to a javascript function to validate and set that validated value to another formbean.how do i do that. it would be nice if someone could provide me with a simple example

Thanks in advance
[ February 09, 2008: Message edited by: preethi venkatarangan ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Originally posted by preethi venkatarangan:
it wud be nice if someone could provide me with a simple example

Please use real words when posting to the forums. Abbreviations such as "wud" in place of "would" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Bear in mind that your form bean exists on the server and the page exists on the client. If this is a new concept, please take a look at this article.

Once the page is sent to the client (browser), the form bean is gone. You can use JavaScript to read the value that the form bean placed in the text field, but it's not directly accessing the form bean.

Likewise, to send the value back to the server to place in another bean, you need to submit a form with the value, or use Ajax.
preethi venkatarangan
Greenhorn

Joined: Jan 21, 2007
Posts: 27
Sorry about that.But we could pass the form bean value to the javascript right.I just wanted to know how to pass the formbean value to the javascript function.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Originally posted by preethi venkatarangan:
Sorry about that.But we could pass the form bean value to the javascript right.I just wanted to know how to pass the formbean value to the javascript function.

No, you cannot pass the value to the JavaScript. By the time the JavaScript executes on the client, chances are the form bean, which is on the server anyways, is long gone.

What you can do is to use the power of JSP to write the value of the bean into the JavaScript itself.


But this cannot be construed as "passing" the value. You will merely be generating JavaScript that has the value hard-coded into it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to pass form bean value to javascript function