猿问

django 一个页面两个表单 怎么提交

django 一个页面两个表单 怎么提交


茅侃侃
浏览 2329回答 2
2回答

犯罪嫌疑人X

如果非要只有一个表单的话,通过js提交:<script type="text/javascript" language="javascript">function submitYouFrom(path){$('form1').action=path;$('form1').submit();}</script><form action="?" name="form1" id="form1"><!-- 表单内容 --><input type="button" value="提交1" onclick="submitYouFrom('地址一')"/><input type="button" value="提交2" onclick="submitYouFrom('地址二')"/></form>123456789101112123456789101112方法3:function submitYouFrom(mets,path){$("#form1").attr("action",path);$("#form1").attr("method",mets);$('#form1').submit();}submitYouFrom('方式',‘路径');

收到一只叮咚

1234567891011121314151617181920212223242526272829办法1.同一个页面中建立两个表单&nbsp;各自提交:<form&nbsp;action="?"&nbsp;name="form1"&nbsp;id="form1">&nbsp;<!--&nbsp;表单内容&nbsp;--><input&nbsp;type="submit"&nbsp;/></form><form&nbsp;action="?"&nbsp;name="form1"&nbsp;id="form1">&nbsp;<!--&nbsp;表单内容&nbsp;--><input&nbsp;type="submit"&nbsp;&nbsp;/></form>1234567812345678办法2:如果非要只有一个表单的话,通过js提交:<script&nbsp;type="text/javascript"&nbsp;language="javascript">function&nbsp;submitYouFrom(path){&nbsp;$('form1').action=path;&nbsp;$('form1').submit();}</script><form&nbsp;action="?"&nbsp;name="form1"&nbsp;id="form1">&nbsp;&nbsp;<!--&nbsp;表单内容&nbsp;--><input&nbsp;type="button"&nbsp;value="提交1"&nbsp;onclick="submitYouFrom('地址一')"/><input&nbsp;type="button"&nbsp;value="提交2"&nbsp;onclick="submitYouFrom('地址二')"/></form>123456789101112123456789101112方法3:function&nbsp;submitYouFrom(mets,path){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$("#form1").attr("action",path);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$("#form1").attr("method",mets);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('#form1').submit();}submitYouFrom('方式',‘路径');&nbsp;
随时随地看视频慕课网APP
我要回答