表单填充的任何javascript事件?

时间:2017-05-17 18:31:42

标签: javascript forms javascript-events

我需要在从后端填充表单值后调用javascript函数。到目前为止,我经历了these javascript events。我没有看到任何可用于此目的的现有事件。

我不想要基于jquery的解决方案。我有什么想法可以做到这一点吗?

编辑: 我在后端填充java(Spring引导)中的值。我没有将值填充到屏幕上的问题。我想知道在屏幕上填充值后是否可以调用任何javascript事件。

Edit2:

enter <form action=# th:action="@{/main}" name="Form2"  th:object="${formObject}" 
             method="post">
                <table 
                    id="collateral_position_table">
                    <tr class="header">
                        <th style="text-align: left" colspan="4"
                            id="collateral_position_title">Collateral Position</th>
                    </tr>
                    <tr>
                        <td >NPV</td>
                        <td ><input 
                        name="otherNpv" id="otherNpv"
                        th:value="${collateralAppliqueInputForm.otherNPV}"
                        style="text-align:right" type="text"/></td>
                        <td >NPV As Of Date</td>                            
                        <td><input 
                        name="otherAsOfDate" id="otherAsOfDate"
                        th:value="${collateralAppliqueInputForm.otherAsOfDate}"
                            style="text-align:right" type="text" /></td>
                    </tr>
                    <tr>
                        <td colspan="4"><input 
                        type="submit" value="Update" name="action"/></td>
                    </tr>
                </table> 
            </form> here

并且控制器填充此表单

  

@RequestMapping(value = {&#34; / main&#34;},method = RequestMethod.POST,params =&#34; action = Update&#34;)   public String updateForm(@Valid @ModelAttribute(value =&#34; formObject&#34;)FormObject formObject,HttpServletRequest request,HttpServletResponse response,BindingResult result,Model model,Principal principal){

     

formObject = methodToPopulateTheForm();

     

model.addAttribute(&#34; formObject&#34;,formObject);

     

}

1 个答案:

答案 0 :(得分:0)

所以我解决方法是在页面主体上使用onload。