Php Javascript在方法中提交表单
我有一种方法可以打印出一组图像的顺序。我需要提交到一个新的php页面 我有一个表单,当前将订单打印到同一页Php Javascript在方法中提交表单,php,javascript,post,Php,Javascript,Post,我有一种方法可以打印出一组图像的顺序。我需要提交到一个新的php页面 我有一个表单,当前将订单打印到同一页 <form action="mainpage.php" method="post"> <div style="clear:both;padding-bottom:10px"> <input type="Button" style="width:100px" value="Show order" onclick="saveImageOrder()"&g
<form action="mainpage.php" method="post">
<div style="clear:both;padding-bottom:10px">
<input type="Button" style="width:100px" value="Show order" onclick="saveImageOrder()">
</div>
如何做到这一点?您可以提交表单(请注意,这没有经过测试): 如果需要先更改操作(要提交到的页面),请执行以下操作: 如果需要异步提交表单,则需要使用XMLHttpRequest或类似的工具。对于纯POST(无ajax),您需要将处理结果(图像顺序id检索)存储在表单字段中:
<input type="hidden" name="imagesorder" value=""/>
然后提交表单,您可以通过替换
<input type="button" .../>
注意最后一行的打字错误。。它应该是$u POST['imagesorder']
document.formname.action = 'some_other_url';
<input type="hidden" name="imagesorder" value=""/>
document.getElementsByName('imagesorder')[0].value = orderString;
<input type="button" .../>
<input type="submit" .../>
$_POST['imagesorder']