2017-08-29 97 views
0

我想在一個頁面上使用一個由多個表單引用的輸入字段。或者我想用<input form="form1,form2,form3,form4" type="text" name="name" required autocomplete="off"/><br>或每次調用輸入字段我提交每一表格在html中添加更多參考輸入參考

<table align="center"> 
    <tr> 
    <td colspan="5" align="center">Group Name: 
     <input form="form1,form2,form3,form4" type="text" name="name" required autocomplete="off"/><br> 
     </td> 
    </tr> 
    <tr> 
    <td> 
    <form id="form1" action="plan.php" method="post"> 
     <input type="hidden" name="number" value="0"><br> 
     <input type="hidden" name="priceplan" value="25"><br><br> 
     <input type="submit" value="10 PAX" style="width:100%; margin-top:0px;" class="button"> 
    </form> 
    </td> 
    <td> 
    <form id="form2" action="plan.php" method="post"> 
    <input type="hidden" name="number" value="0"><br> 
    <input type="hidden" name="priceplan" value="2"><br><br> 
    <input type="submit" value="10 People" style="width:100%; margin-top:0px;" class="button"> 
    </form> 
    </td> 
    <td> 
    <form id="form3" action="plan.php" method="post"> 
     <input type="hidden" name="number" value="0"><br> 
     <input type="hidden" name="priceplan" value="3"><br><br> 
    <input type="submit" value="20 People" style="width:100%; margin-top:0px;" class="button"> 
    </form> 
    </td> 
    <td> 
    <form id="form4" action="plan.php" method="post"> 
    <input type="hidden" name="number" value="0"><br> 
    <input type="hidden" name="priceplan" value="4"><br><br> 
    <input type="submit" value="30 People" style="width:100%; margin-top:0px;" class="button"> 
    </form> 
    </td> 
    <td> 
    <form id="form5" action="plan.php" method="post"> 
    <input type="hidden" name="number" value="0"><br> 
    <input type="hidden" name="priceplan" value="5"><br><br> 
    <input type="submit" value="40 People" style="width:100%; margin-top:0px;" class="button"> 
    </form> 
    </td> 
</tr> 
</table> 

我想用<input form="form1,form2,form3,form4" type="text" name="name" required autocomplete="off"/><br>或每次調用輸入字段我提交每一表格

+0

請澄清你的問題;它沒有多大意義。 – j08691

+0

這在HTML5中是不可能的。根據你爲什麼需要這個,你最好的選擇可能是使用JavaScript克隆字段並在每個表單中插入一個副本,或者在表單中創建隱藏字段,這些字段會自動填充一個「原始」的內容,如果用戶界面要求它只能在一個地方,或者像...... – CBroe

+0

我在頁面上有多個表單,但不想在每個表單上重複輸入字段,所以我決定在我的表格中的某個位置每次我按下發送按鈕時,它也會從組名中提交值。 –

回答

0

你追加它

  • 第一你給烏爾唯一輸入自己的ID(ID =「uniqueInput」)
  • 然後提交:您可以使用Javacsript這裏是使用jQuery的例子做到這一點窗體
$('form').submit(function(e){ 
    e.preventDefault(); 
    $('<input>').attr({ 
    type: 'hidden', 
    id: 'foo', 
    name: 'bar', 
    value: $('#uniqueInput').val() 
    }).appendTo($(this)); 
})