title: Can't execute Javascript in jsf page
body: <p>I'm new to jsf. I have been trying to do a simple Javascript function with commandbutton. I tried many times but wasn't even able to do an alert message. This is part of my code. Please can anyone guide me, and tell what is wrong, and what I should do to make it run?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"&gt;
  &lt;h:head&gt;
    &lt;script type="text/javascript"&gt;
    function test(){
      alert('test');
      alert(document.getElementById('frmDashBoard:testbt').value);
    }
    &lt;/script&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
    &lt;ui:composition template="../../template/commonLayout.xhtml"&gt; 
      &lt;ui:define name="content"&gt;
        &lt;div&gt;
          &lt;h:form id="frmdashboard"&gt;
            &lt;div name="form_panel" style="width: 984px"&gt;
                 &lt;h:commandButton id="testbt" value="#{message.btn_dashboard_search}" action="#{searchBLAction.doAction}" onclick="test()" /&gt;
            &lt;/div&gt;
          &lt;/h:form&gt;
        &lt;/div&gt;
      &lt;/ui:define&gt;
    &lt;/ui:composition&gt;     
  &lt;/h:body&gt; 
  &lt;/html&gt;
  </code></pre>