Getting [Object HTMLInputElement] error : <p>looping through a json encoded output for a Month Year value, and trying to convert it a month number before passing it to next step in code ...</p>

<pre><code>... foreach loop
    var month_number = null;
    var dateOf = JSON.stringify(v.date);
    if(dateOf.indexOf("January")&gt;-1){month_number=1}else
    if(dateOf.indexOf("February")&gt;-1){month_number=2}else
    if(dateOf.indexOf("March")&gt;-1){month_number=3}
  });

  htmlStr += '&lt;input type="hidden" id="month_number" value="' + month_number + '" /&gt;';
</code></pre>

<p>returning [Object HTMLInputElement] for month_number ... everything else is working ...</p>
