how to pass form bean value to javascript function

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

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

posted Feb 09, 2008 15:46:00

0

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.

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com