I don't mean that asking others to write the script for me,I have also tried many times as i am a beginner of javascript only.I hope you can understand.
I am trying to use onchange, but i don't know how to put the option value in the array.
You can then add that to the end of an array either by using the index of the array :
var myArray = new Array();
myArray[0] = document.formName.elementName.options[document.formName.elementName.selectedIndex]
Or you could use push to add it directly to the end of the array :
var myArray = new Array();
myArray.push(document.formName.elementName.options[document.formName.elementName.selectedIndex])
If what you actually wanted was to add all the values of the combo inside an array you could use a for loop and add the option's value inside the array using push
var formElm = document.formName.elementName.options;
var len = formElm.length;
var myArray = new Array();
for (var i = 0; i < len; i++)
{
myArray.push(formElm)
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.