title: Retrieve thymeleaf object value from JavaScript
body: <p>I have simple thymeleaf template gets objects from controller, in that template I have select with options coming from controller as an array/list, want to access the selected option's value. But I am getting memory reference as string from JavaScript</p>
  <p>Controller:</p>
  <pre><code>modelAndView.addObject(&quot;banks&quot;,screenDetail.getBanks().toArray());
  </code></pre>
  <p>HTML:</p>
  <pre><code>&lt;select id=&quot;chooseBank&quot; name=&quot;bankId&quot; style=&quot;width:100%&quot; class=&quot;de-intl-select&quot; onchange=&quot;handleBank()&quot;&gt;
      &lt;option value=&quot;&quot;&gt;&lt;/option&gt;
      &lt;option th:each=&quot;bank:${banks}&quot; th:text=&quot;${bank.name}&quot;
              th:value=&quot;${bank}&quot;&gt;
      &lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  <p>Javascript:</p>
  <pre><code>function handleBank()
  {
      var chooseBankField = document.getElementById('chooseBank');
      var bank = chooseBankField.options[chooseBankField.selectedIndex].value;
      console.log(&quot;PRINT: &quot;+ bank);
      console.log(&quot;PRINT: &quot;+ bank.id);
  }
  </code></pre>
  <p>first its prints the object reference as sting, i,e com.test.Bank@L1232142
  Second line print undefined.</p>
  <p>Note: Bank is pojo with fields like id, name, logo etc.</p>
  <p>Where I am going wring here ?</p>