2014-04-02 49 views
0

作爲html表單的一部分,我有一個選擇框。清除<option value>表單提交

<select id="test" name="test"> 
<option value="text1">Text1</option> 
<option value="text2">Text2</option> 
</select> 
<input type="text" id="my_text_box" name="my_text_box" class="hidden" /> 

使用javascript,我怎樣才能從結果的形式電子郵件中刪除值「text2」給我?

編輯:

我需要保持Text2。當用戶選擇此選項時,選擇框將變爲文本輸入,使用下面的腳本。我需要從結果文本輸入中刪除「text2」值。

window.onload = function(){ 
var dropDown = document.getElementById("test"); 
dropDown.onchange = function() { 
var dropDownValue = this.value; 
if (dropDownValue == "text2") { 
    dropDown.style.display = 'none'; 
    var textBox = document.getElementById("my_text_box"); 
    textBox.style.display = 'inline'; 
    textBox.value = 'Please enter something..'; 
    } else { 
    dropDown.style.display = 'inline'; 
    textBox.style.display = 'none'; 
    }; 

    } 
+0

你做任何嘗試? – Girish

+1

你是什麼意思刪除值「text2」。那你爲什麼不擺脫整個'