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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -