开发者

How to copy the form values

I have written two forms

<g:fom name ="report_html" action="htmlReport">
    <g:render template="/templates/filterTemplate" />
    <input type ="submit" value ="Generate Html Report" id ="html_report_submit"> 
</g:form>
<g:form 开发者_如何转开发name ="pdf_report" action = "pdfReport">
  <input type ="submit" value ="Generate Pdf Report" id ="pdf_report_submit"> 
</g:form>

_filterTemplate.gsp has many fields

Now ,i want when the form "report_html" is submitted the values should be available so that when the "pdf_report" form is submitted the same values should be passed.so how to copy the form elements and used for the other form .


Access them via $("#ElementID").val()


You could use two hidden field and keep thos in sync with some javascript:

<g:fom name ="report_html" action="htmlReport">
  Start Date: <input type ="text" name ="startdate" id ="startdate" value=""> 
  End Date: <input type ="text" name ="enddate" id ="enddate" value=""> 
  <input type ="submit" value ="Generate Html Report" id ="html_report_submit"> 
</g:form>
<g:form name ="pdf report" action = "pdfReport">
    <input type ="hidden" name ="startdate" id ="startdatecopy" value=""> 
    <input type ="hidden" name ="enddate" id ="enddatecopy" value=""> 
  <input type ="submit" value ="Generate Pdf Report" id ="html_report_submit"> 
</g:form>

$('#startdate, #enddate').keyup(function(){
    var id = '#'+this.id+"copy";
    $(id).val($(this).val());
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜