2013-03-26 55 views
1

我希望能够将表单中的信息发布到两个位置。该表单当前发布到一个位置。简单的html表单发布到两个不同的位置

<form name="input" action="display.php" method="post"> 
    search: <input type="text" name="item"> 
    title: <input type="text" name="title"> 
    Distance: 
    <select type="text" name="distance"> 
     <option value="5">5 miles</option> 
     <option value="10">10 miles</option> 
     <option value="15">15 miles</option> 
    </select> 
</form> 

我已经试过

<form name="input" action="display.php", "info.php" method="post"> 

希望它会发布到两个及Display.php的info.php的,但没有运气。

+3

我不认为你可以,但一种解决方法是使目标位置发送表单数据到第二页。 – ophintor 2013-03-26 13:09:30

+0

这是不可能的,以正常形式给出两种形式的动作,如果你真的需要它,你可以使用ajax – 2013-03-26 13:09:41

+1

做到这一点,你只需发布到'display.php',然后从该页面发布到'info.php'? – chriz 2013-03-26 13:09:52

回答

0

最好的办法是使用史努比,因为它不会使用卷曲。 (你可能会也可能不会,这个班不需要)。 类可以从以下网址下载:http://sourceforge.net/projects/snoopy/ 所有你需要做的包括这个类,并使用此代码多个职位:

$snoopy = new Snoopy; 

    $submit_url = "url1.php"; 

    $submit_vars["foo"] = "bar"; 
    $submit_vars["key"] = "value"; 
    $submit_vars["input-name"] = "input-value"; 
    //making sense on what these are? 

    $snoopy->submit($submit_url,$submit_vars); 
    //additionaly you can print the results with: 
    //print $snoopy->results; 

    //then move to the next submit url 
    //but, remember! You must instantiate a new class 

    $snoopy2 = new Snoopy; 


$submit_url = "url2.php"; 

$submit_vars["foo"] = "bar"; 
$submit_vars["key"] = "value"; 
$submit_vars["input-name"] = "input-value"; 

$snoopy2->submit($submit_url,$submit_vars); 
+0

推荐的班级差不多5岁。 – nickb 2013-03-26 13:21:55

2

你为什么不使用ajax这一点。它会帮助你将2个请求发送到2个不同的页面。

$.ajax({ 
      type: "POST", 
      url : "form.php", 
      data: {'field1':field1,'field2':field2}, 
      success: function(msg){ 
       // get response here 
       } 
      }); 

$.ajax({ 
      type: "POST", 
      url : "display.php", 
      data: {'field1':field1,'field2':field2}, 
      success: function(msg){ 
       // get response here 
       } 
      });