Reputation: 1173
As part of a html form, i have a select box.
<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?
EDIT:
I need to keep 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.
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';
};
}
Upvotes: 0
Views: 115
Reputation: 15490
document.getElementById('test').options[1].value = 'emailId';
Upvotes: 2