title: Passing parameters to a javascript function called through 'onclick' attribute
body: <p>I need to create links on webpage which call a javascript function with different parameters on being triggered by <code>onclick</code> event. Thus function needs to be passed a paramter. </p>
  
  <p>In my code as shown below, I am passing a parameter to <code>wr()</code> function when calling from <code>onclick</code> within <code>commandLink</code>. Howver the code doesnt successfully execute if I pass <code>i</code> as parameter to <code>wr()</code> function within <code>onclick</code>, but is successful if I pass a constant ie, <code>wr(4)</code>. How can I successfully pass a variable parameter to this javascript function ?</p>
  
  <pre><code>            &lt;h:form&gt;
                  &lt;ui:repeat value="#{bean.list}" var="i"&gt;
                      &lt;p:commandLink onclick="wr(i)" value="#{i}" /&gt;&lt;br/&gt;
                  &lt;/ui:repeat&gt;
              &lt;/h:form&gt;
  
              &lt;p id="e"&gt;fd&lt;/p&gt;
  
              &lt;script type="text/javascript" &gt;
                  function wr(i){
                      document.getElementById("e").innerHTML="this is "+i+ " !";
                  }
              &lt;/script&gt;
  </code></pre>