2013-05-15 40 views
0

您好我需要編寫代碼的表單,查詢外部網站與三個提交按鈕。並且每個提交按鈕將發送一些通用的輸入字段和一些與特定個人身體相關的字段。我相信我需要使用JavaScript,但我不確定我能做些什麼。以下是表格的結構。表單與多個提交按鈕,查詢外部網站

<form action="external website" method="post"> 
{{ form_with common input selectors }} 

<!-- if submit Option one is used --> 
<input type="text" name="fixed" value="option one"> 

<!-- if submit Option two is used --> 
<input type="text" name="fixed" value="option two"> 

<!-- if submit Option three is used --> 
<input type="text" name="fixed" value="option three"> 

<input type="submit" name="Option one" value="option one" /> 
<input type="submit" name="Option two" value="option two" /> 
<input type="submit" name="Option three" value="option three" /> 
</form> 

任何專家的幫助將不勝感激!

收藏分享

+0

行動網址是否會有所不同 –

+0

我做了一些我認爲與今天工作時非常相似的事情。但我不確定你需要完成什麼。你能澄清嗎? – user1596138

+0

我會寫一個例子。 – user1596138

回答

0

如果我正確理解你的問題,這將是你的答案。 簡單地發送三個值中的一個作爲表單的一部分似乎是你要求的。

這個問題相當模糊,但這可能沒有幫助。

<!-- ONLY ONE INPUT FIELD IS NEEDED --> 
<input id="SOMETHING" type="text" name="fixed" value=""> 


<input type="submit" name="Option one" onClick="firstbutton();" value="option one" /> 
<input type="submit" name="Option two" onClick="secondbutton();" value="option two" /> 
<input type="submit" name="Option three" onClick="thirdbutton();" value="option three" /> 
</form> 

<script type="text/javascript"> 
var input1 = "whatever input 1 will be"; 
var input2 = "whatever input 2 will be"; 
var input3 = "whatever input 3 will be"; 
function firstbutton() { 
document.getElementById('SOMETHING').value = input1; 
} 
function secondbutton() { 
document.getElementById('SOMETHING').value = input2; 
} 
function thirdbutton() { 
document.getElementById('SOMETHING').value = input3; 
} 
</script> 
+0

嗨這個問題已經解決了!謝謝大家! –

0

分三路的提交成三個獨立的形式,並且給每個形成不同的ID(Form1中,窗口2,form3)。它會容易得多。如果您將AJAX掛鉤到這些表單,那麼您就不必擔心鏈接到這些表單的其他頁面的其餘部分。