javascript - Using phantomsjs, how to get a value and assign it to an element of an array? -


the following piece of code when ran produces "undefined".

var getlist = document.getelementbyid('lbexercises').option; console.log(getlist); 

the html wish data follows:

<select id="lbexercises" class="listbox" style="height:400px;width:350px;"                 name="lbexercises" size="4"> <option value="1270">value want extract 2</option> 

the issue js code - if helps im running code using phantomsjs filename.js

thanks.

you first value of first option this:

var getlist = document.getelementbyid('lbexercises'); console.log(getlist.options[0].value); 

see jsfiddle:

http://jsfiddle.net/3llbs/

this how assign element of array:

var anarray = new array(); anarray[0] = 123; anarray[1] = 456; anarray[2] = 789;  // assign new value anarray[1] = getlist.options[0].value;  console.log(anarray[1]); 

see jsfiddle:

http://jsfiddle.net/3llbs/1/


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -