L
L
low molecular macro2020-10-03 18:01:49
HTML
low molecular macro, 2020-10-03 18:01:49

Why does the console output only the first word from the value of the button element?

There is this form:

<form action="/" method="POST">
    <input type="text" name="newItem" placeholder="new task" autocomplete="off">
    <button type="submit" name="list" value=<%= listTitle %> >+</button>
</form>

which listTitleis passed as follows
res.render("list", {listTitle: "Work List Title", newListItem: workItems})

But when I try to output the value listto the console node, I only get the first word before the space - Work . But if I set listnot a variable, but the string "Work List Title" , then the entire line is displayed in the console. Explain, please, why so?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-10-03
@molekulyarniy

because

<button type="submit" name="list" value=<%= listTitle %> >+</button>
at the output gives
<button type="submit" name="list" value=Work List Title >+</button>
those. buttonwith attributes . You can do like thisvalue="Work" List="" Title=""
<button type="submit" name="list" value="<%= listTitle %>" >+</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question