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:
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:
Comments
Post a Comment