This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Update OutputText using Java Script. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Update OutputText using Java Script." Watch "Update OutputText using Java Script." New topic
Author

Update OutputText using Java Script.

Sudeep Agrawal
Ranch Hand

Joined: May 31, 2006
Posts: 34
Could someone please tell me how can I update the value of outputText via. Java Scripts.
I have this huge dynamic datagrid, with many columns two of which are to enter pin numbers per row (enter pin & reEnter Pin).

I made a Java Script for the onchange event of the reEnter Pin, that compares its value with the enter Pin. In case the values are not the same I need an indication on that row : "*" in bold red, to indicate that the values are not correct.

The * , being an outputText does not update with JavaScript.

Alternately , I tried using ValueChangeListener, but it didnot work as well.

Please help.
g madhava
Ranch Hand

Joined: Sep 14, 2001
Posts: 85
Since you wanted this functionality using javascript - This question should ideally have been posted in "javascript" forum.

I am assuming you are already doing the below.

The HTML code generated is the starting point in order to get this thing done.
Use the "view source" feature available in the browser which you are using,
You need to apply DOM concepts in order to iterate through the elements using javascript DOM API.

What you might be missing is the place holder for the '*'.
For this you have to create a 'DIV' element. Usually this can be created directly by having hutputText with "ID" attribute. Set the style for this 'DIV' element to 'display:none' initially.
Now in your onchange() / onBlur() function, you could have the function that sets the styple

Note - This can be done easily if you have consistent naming for the field values. A sample example is as below. You would have to replace the parameters appropriately if you plan to use this function below.

g madhava
Ranch Hand

Joined: Sep 14, 2001
Posts: 85
Replace the "onblurfunction" keyword with the "onblur" function of javascript.

I had write the above since javaranch is parsing the content of the response
A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
If you would like to try it out in JSF, you can use a validator method in your backing bean. Set the rendered attribute of outputText '*' to true if the validation fails. You may want to bind the enter pin and the reenter pin inputText elements as well as outputText element to backing bean properties in order to access them in your validator method.

I have this huge dynamic datagrid, with many columns two of which are to enter pin numbers per row (enter pin & reEnter Pin).


Do you mean that you have these enter pin elements in every row? If so you may also need to bind the datagrid to a backing bean property in order to loop through the rows.
Hope this gives you some idea.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Update OutputText using Java Script.
 
Similar Threads
color row-x
comparing time
Text box JS for '00000' values
Input row select on data table does not get called
Need help with DigestUtils SHA encryption