Search code examples
jquerypythonhtmlbottle

Input hidden value propery when value has spaces


I have a form with the hidden value holding onto the name of a question that is stored in a mysql database. The issue I am having is that the hidden value only holds onto the first part of the name. For example, in my template:

% for d in data
  <input type="hidden" name="question_name" value={{d["name"]}}>
% end

d["name"] would be something like "math question". When I checked the question_name value on the server, and the hidden input value in jQuery, the result is math and it leaves out anything coming after the first word. What could be causing this?


Solution

  • You need to wrap it with quotes other ways the remaining part is considered as another attribute of the tag.

    % for d in data
      <input type="hidden" name="question_name" value="{{d["name"]}}">
    % end