• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JQuery: How to get the value updated in a javascript file

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a inputBox in the xhtml page like this
<h:inputText id="id" value="#{bean.value}">.
I use Firefox browser, enter the value. Its value will be updated in a javascript file by using jquery like this jquery(this).val("test"); The test value should be shown on the browser but i didn't see.
Thanks a lot for any help.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, remember how to get a id of a component in jsf: subview:form:component

in javascript code of your browser you can see the component id

example:
<f:subview id="prueba">
<h:form id="formulario">
<h:inputtext id="text" value=#{myBean.value}/>
</f:subview>
</h:form>

I do something like this:

javascript:

var idObject=document.getElementById('prueba:formulario:text');

$(idObject).attr('value','myvalue');

good luck.
sorry my bad english.
 
Sheriff
Posts: 67752
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
"May TVIVY",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Bear Bibeault
Sheriff
Posts: 67752
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
This is much more about jQuery and JavaScript than JSF, so I've moved it to the appropriate forum.
 
Bear Bibeault
Sheriff
Posts: 67752
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 May TVIVY:
... by using jquery like this jquery(this).val("test");


jquery is not valid. It should be jQuery or $.

And, without knowing what "this" is, we cannot diagnose this. If the value of the element is not being updated, most likely "this" is not referring to the element that you think it is.
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic