Reputation: 11
I have a javascript that I am trying to write to do a comparison with a list of objects. But first I need to pull the value from the below HTML.
<div class="no_icon" style="width:100%;display:-moz-deck;">
<input title="model1" onfocus="thtmlbSaveKeyboardFocus('product_type');" class="class1"
style="width:100%;" dir="ltr" name="product_type" id="product_type" maxlength="40"
onkeydown="if(htmlbEnterKey(event)==true){return
htmlbSL(this,2,'product_type:submitonenter','0')};" value="model1" disabled="disabled"></div>
my issue happens when I try to pull the information I need from the page. I have tried several versions of the "document.getElement" commands,(TagName,ID,Class) but I cannot seem to pull the information i need.
When I tried to see if i could even access the input I received either a null or undefined return. but when I do a
var test=document.getElementsByTagName(product_type.class1");
console.log(test);
I get a return of object# nodelist
After doing some digging into nodelists I have discovered that "product_type.class1" has an attribute of namedNodeMap. But nothing i seem to do can pull the value section from within the HTML.
What I need is a way to get the value of the "value="field.
Upvotes: 0
Views: 412
Reputation: 29941
I think you will have more success using querySelector
instead of getElementsByTagName
:
var input = document.querySelector("[name='product_type']");
console.log(input.value);
Upvotes: 1