我有一个表单,我想将表单的值传递给操作。我也不想使用提交按钮并想使用 struts2 anchor 标记。这是我的以下代码:
<s:form id="form" theme="xhtml" >
<sj:datepicker id="startDate" name="startDate" label="Start Date" required="true"/>
<sj:datepicker id="endDate" name="endDate" label="End Date" required="true" />
</s:form>
<s:url action="excelExport" id="excelurl" >
</s:url>
<s:a formId="form" href="%{excelurl}" onclick="document.forms['form'].submit();" >Export</s:a>
这里的问题是开始日期和结束日期没有传递给操作。有人可以建议如何将表单值传递给操作。顺便说一句,我正在使用 struts2 jquery 插件。如果需要更多信息,请告诉我。提前致谢!
最佳答案
href="%{excelurl}" onclick="document.forms['form'].submit();
据我所知,一旦您点击 anchor 标记,href就会被调用。 能否去掉href,在form标签中提供action名称,这样点击就会调用js提交
这可能有帮助:)
关于javascript - 如何使用 anchor 标记将表单值传递给操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19820471/