Change the value of a dropdown if it is equal to something
Posted
by
Jake Neal
on Stack Overflow
See other posts from Stack Overflow
or by Jake Neal
Published on 2012-11-09T10:59:01Z
Indexed on
2012/11/09
10:59 UTC
Read the original article
Hit count: 199
JavaScript
Sorry if this question has already been asked and answered, but I couldn't find anything specifically for my needs. I have a form that has placeholders and javascript to make sure the form isn't submitted with the placeholders still there. There is a dropdown box that has the value of 'Best time to call'. What I want to do is if this value is passed as the default, I want it to change to something like "n/a" or a blank value. I have achieved this with the comments box using the following javascript, but it doesn't seem to work the same for the dropdown:
var comments=document.getElementById('comments').value;
if (comments=="Comments")
{
document.getElementById('comments').value="";
}
This isn't a required field so I can't have an alert come up, so I just need to value to be changed if submitted as 'Best time to call'. Hope I have explained everything correctly
© Stack Overflow or respective owner