1) How to retrieve the text of the single option using the value given to it in option tag(irrespective of which option is selected), say I have selected Pineapple but I want to get the name of some other fruit later in the program (eg: I selected Pineapple, but later in the program I want to know what is the fruit in Option tag with value=3 ie Orange here), and I want to do it using value given to it. (say retrieving Orange from its value 3)
Yes we have lot of options if it is the selected item but what if it is not the one which is currently selected?I want to do it using javascript.
2) How to retrieve all the elements using value given to it in option tag.
3) And also how to sort it using the value(in option tag) given to it and store it in an array? (intention is not sort in alphabetical order but sort using the value given to it option tag, I should be able to store the array with the elements in the order Apple,Banana,Orange,Pineapple)
HTML STRUCTURE
<form>Select your favorite fruit:
<select id="mySelect">
<option value="4">Pineapple</option>
<option value="2">Banana</option>
<option value="3">Orange</option>
<option value="1">Apple</option>
</select>
</form>
(sorry for putting many questions together in a single place, am new to stackoverflow)