How can I know the id of a JSF component so I can use in Javascript

前端 未结 6 1331
北海茫月
北海茫月 2020-11-22 02:47

Problem: Sometimes you will want to access a component from javascript with getElementById, but id\'s are generated dynamically in JSF, so you

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 03:14

    
      
    
    

    This is a small example of jsf. Now I will write javascript code to get the value of the above jsf component:

        var x = document.getElementById('myform:name').value; //here x will be of string type
    
       var y= parseInt(x,10); //here we converted x into Integer type and can do the 
                               //arithmetic operations as well
    

提交回复
热议问题