• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to pass form bean value to javascript function

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic