Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes How to set value of an input using jQuery ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "How to set value of an input using jQuery ?" Watch "How to set value of an input using jQuery ?" New topic
Author

How to set value of an input using jQuery ?

Radu Mircea
Ranch Hand

Joined: Jun 14, 2009
Posts: 45
Hi ,

I am trying to change the value of an input depending on selection from a combo box, so is user selects "Yes" from combo box the input should contain "test" value and than
if user selects "No" the input should be empty , "test" value remove from it.

I tryed to do it runing the following code:


Running it in this version the javascript error "Object doesn't support this property or method" still occurs.(when i change selection in combo box)

After removing

if ($(this).val() == true)

condtion and additionals { } the first javascript error is gone but another is raised saying "null is 'null' or not an object", when i change selection in combo box.

I am not sure if only rich faces jars (3.3.2) had support for this jQuery implementatios like using "$" and other methods (may be some jQuery libraries are nedded), this could be one reason why this is not working in my opinion.

Please, any idea about how to implement this behavior are welcomed.

Regards,
Radu
Suraj Jadhav
Greenhorn

Joined: Mar 10, 2010
Posts: 25
Hey Radu,

I am also new to JQuery. But You may try following code.



Also looks like there is error in your script. You have written but I guess, myInputStyleClass is the style class and not the input control. I will suggest you to try putting some alert() into code to get the values.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56168
    
  13

Please do not post JSF markup in an HTML forum.

We need to see the generated HTML, not the JSF which is meaningless on the client.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Radu Mircea
Ranch Hand

Joined: Jun 14, 2009
Posts: 45
Hi ,

Thanks for replays.

@Bear ok, next time i will take care about it.

@Suraj your example was very helpful ;), also i should say you that you can use a css class as selector, so there are no errors in my script .

I solved this issue.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to set value of an input using jQuery ?
 
Similar Threads
Is Backing bean Required
can anybody help ??
Can you have condition in <h:selectOneMenu> ?
SelectOneMenu Validation
h:selectOneMenu problem evaluating to empty String