开发者

Can´t trigger a javaScript method on the onload event of a form

I am trying to call a JavaScript method on the onload() event of a form. Here is the code for the javaScript:

<script type="text/javascript">  
    function gback(){
                document.FM.action = "<c:url value='FModificar'/>";
                document.FM.method = "get";
                document.FM.submit();
              } 

               function DelF() {
                        jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {

                                 if (r == true) {
                                     $("form[name='FEl']").submit();

                                    } else {
                                      return false;
                                    }
                        });
                    }

               function Check(msg){
                   if(msg.toString().length > 5){                 
                     jAlert('success', msg, 'Success');

                   }
               }

</script> 

And here is the html code:

 <%-- FornecedorList is requested --%>
                        <c:if test="${!empty VFornecedorList}">

                            <table id="ProductTable" class="detailsTable" onload="Check(${CFP})">

                                    <tr class="header">
                                        <th colspan="7" >Fornecedor</th>
                                    </tr>

                                    <tr class="tableHeading">
                                        <td>ID</td>
                                        <td>Nome</td>
                                        <td>Endereço</td>
                                        <td>Descrição</td>
                                        <td>Nº de Celulare</td>
                                        <td>Nº de Telefone</td>
                                        <td>Email</td>    
          开发者_C百科                              <td>Fax</td> 

                                    </tr>

                                    <c:forEach var="VForn" items="${VFornecedorList}" varStatus="iter">

                                        <tr class="${'white'} tableRow">   
                                            <td>${VForn.getFid()}</td>
                                            <td>${VForn.getFNome()}</td>
                                            <td>${VForn.getFEndereco()}</td>
                                            <td>${VForn.getFDescricao()}</td>
                                            <td>${VForn.getFNCel()}</td>
                                            <td>${VForn.getFNTel()}</td>
                                            <td>${VForn.getFEmail()}</td>    
                                            <td>${VForn.getFFax()}</td> 
                                        </tr>

                                    </c:forEach>

                                </table>

                            </c:if> 
                    <%-- END FornecedorList is requested --%>   

Also the method receives a parameter from the controller. Here is the code:

//Add a Fornecedor
             fornece = transManager.addfornecedor(ID, nome, endereço, email, cell, tel, fax, des, Fact);
             String Fmsg = "";
             if (!fornece.equals(""))
                   Fmsg = "Fornecedor " + nome + " foi criado"; 

            if(!PFtp.equals("Prodft")){ 
             Fornecedor = transManager.getLEnt("fornecedor");
             request.setAttribute("CFP",Fmsg);
             request.setAttribute("VFornecedorList",Fornecedor);
             userPath = "/Fornecedor";  
            }

I am using Netbeans 7.0.1 and Firefox 5. So any advice would be much appreciated.


Forms don't have a load event. A form is just part of a document, not something that loads independently (such as a whole document, or the content or an iframe, or an image).

If you want to run some JS as soon as a form has been parsed, do this:

</form>
<script> your js here </script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜