0

for some reason i get null values. Im filling the value from label input with a defaultvalue form the database That works fine

<label for="input_first_name">Vorname:</label> 
<input id="input_first_name" value=<%out.print(html_contents.get("vorname"));%> type="text" class="form-control">

Later in script:

data["vorname"] = document.querySelector('#input_first_name').value;

I thought about the scriptfunction takes the value of the label and not the label/input. And the label value is empty. If so. How can I change that?

  • Possibly related to this [other question](https://stackoverflow.com/questions/8312820/jquery-val-vs-attrvalue). – Andrew S Dec 08 '18 at 18:05
  • (1) I do not know what is stored in `html_contents.get("vorname")`, but I bet it does not contain the quotes to be rendered correctly as HTML attribute. (2) It is much clearer to use `<%= ... %>` instead of `<% out.print(...); %>` in JSP. So can you please change the JSP code to: `" type="text" class="form-control">` – Nikos Paraskevopoulos Dec 09 '18 at 08:07

0 Answers0