简体   繁体   English

明确 <option value>在表格提交

[英]Clear <option value> on form submit

As part of a html form, i have a select box. 作为html表单的一部分,我有一个选择框。

<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" />

Using javascript, how can I remove the value "text2" from the results the form emails to me? 使用javascript,如何从表格电子邮件给我的结果中删除值“text2”?

EDIT: 编辑:

I need to keep Text2. 我需要保留Text2。 When the user selects this, the select box changes to a text input, using the script below. 当用户选择此选项时,使用下面的脚本将选择框更改为文本输入。 I need to remove the value "text2" from the resulting text input. 我需要从结果文本输入中删除值“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';
   };

   }
 document.getElementById('test').options[1].value = 'emailId';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM