title: Function is not defined - jsf/javascript
body: <p>I'm not able to call my javascript function. I've tried in the onChange SelectMenu now and tag ajax, but both are giving the following message:</p>
  
  <blockquote>
    <p>Message: 'sumarFilas' is not defined.</p>
  </blockquote>
  
  <p>Follows function and jsf with the function call:</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  
      var numfilasRelacion=1;
      var form=document.theForm;
      var valorNRN="";
  
      function  sumaRelacion()    {
  
      var miTablaRelacion = document.getElementById("form:j_idt115_panel");
  
      var fila = document.createElement("tr");
      var celda1 = document.createElement("td");
      var celda2 = document.createElement("td");
      var celda3 = document.createElement("td");
      var celda4 = document.createElement("td");
      var celda5 = document.createElement("td");
  
      numfilasRelacion=miTablaRelacion.getElementsByTagName("tr").length + 1 ;
  
      celda1.innerHTML = "&lt;p:inputText id='inicioRango' /&gt;";
      celda2.innerHTML = "&lt;p:inputText id='finalRango' /&gt;";
      celda3.innerHTML = "&lt;p:inputText id='numeroGrupoId' /&gt;";
      celda4.innerHTML = "&lt;p:inputText id='checkpto'/&gt;";
      celda5.innerHTML = "&lt;p:inputText id='checkptoH'/&gt;";
      fila.appendChild(celda1);
      fila.appendChild(celda2);
      fila.appendChild(celda3);
      fila.appendChild(celda4);
      fila.appendChild(celda5);
      miTablaRelacion.appendChild(fila);
      }
  
      function restarFilas(rangos) {
      var miTablaRelacion = document.getElementById("form:j_idt115_panel");
      var i = numfilasRelacion-1;
      do{
          miTablaRelacion.deleteRow(i);
          numfilasRelacion=numfilasRelacion-1;
          i=i-1;
        }
      while (miTablaRelacion.rows.length != rangos)
      }
  
      function sumarFilas(){
          alert("sumarFilas");
      var numfilas=numfilasRelacion;
      var rangos = document.getElementById("form:j_idt115_panel").value;
      if(rangos&gt;numfilas){                                
          for(var i=0;rangos-numfilas&gt;i;i++){
          sumaRelacion();
          }
      }else{
          restarFilas(rangos);
      }
       }
  &lt;/script&gt;
  </code></pre>
  
  <p>The jsf:</p>
  
  <pre><code>&lt;h:outputText value="Nº Intervalo a Portar:" /&gt;
  &lt;p:selectOneMenu value="#{bean.parametro.intervalo}"&gt;
      &lt;f:selectItem itemLabel="1" itemValue="1" /&gt;
      &lt;f:selectItem itemLabel="2" itemValue="2" /&gt;
      &lt;f:selectItem itemLabel="3" itemValue="3" /&gt;
      &lt;f:selectItem itemLabel="4" itemValue="4" /&gt;
      &lt;f:selectItem itemLabel="5" itemValue="5" /&gt;
      &lt;f:selectItem itemLabel="6" itemValue="6" /&gt;
      &lt;f:selectItem itemLabel="7" itemValue="7" /&gt;
      &lt;f:selectItem itemLabel="8" itemValue="8" /&gt;
      &lt;f:selectItem itemLabel="9" itemValue="9" /&gt;
      &lt;f:selectItem itemLabel="10" itemValue="10" /&gt;
      &lt;f:ajax event="change" onevent="sumarFilas"&gt;&lt;/f:ajax&gt;    
  
  &lt;/p:selectOneMenu&gt;
  
  &lt;h:panelGrid columns="6" style="margin-bottom:10px" cellpadding="5"
      id="pgrid121"&gt;
  
      &lt;h:outputText value="Portabilidade Grupo" id="pg1" /&gt;
      &lt;p:selectBooleanCheckbox
          value="#{bean.parametro.portabilidadeGrupo}" id="pg11" /&gt;
  
      &lt;h:outputLabel for="numInicial1" value="Nº Inicial Int:" id="ni1" /&gt;
      &lt;p:inputText id="numInicial1" value="#{bean.parametro.numInicial}" /&gt;
  
      &lt;h:outputLabel for="numFinal1" value="Nº Final Int:" id="nf1" /&gt;
      &lt;p:inputText id="numFinal1" value="#{bean.parametro.numFinal}" /&gt;
  
      &lt;h:outputLabel for="idGrupo1" value="Id do Grupo:" id="ig1" /&gt;
      &lt;p:inputText id="idGrupo1" value="#{bean.parametro.idgrupo}" /&gt;
  
      &lt;h:outputText value="PTO" id="pt1" /&gt;
      &lt;p:selectBooleanCheckbox value="#{bean.parametro.pto}" id="pt11" /&gt;
  
  &lt;/h:panelGrid&gt;
  </code></pre>
  
  <p>Thanks!</p>