0

I have a dropdown menu, that consists of elements from a db table:

    <li class="dropdown">
      <a class="dropdown-toggle" data-toggle="dropdown"> 
        Production lines 
        <span class="caret"></span>
      </a>
      <ul class="dropdown-menu">
        {% for line in lines %}
          <option>{{ line[0] }}</option>
        {% endfor %}
      </ul>
    </li>

I need to make it so that when the user clicks an element, the value of the chosen element is submitted.

Currently I only know how submit something through forms with a submit button. Would appreciate if someone listed out some approaches on how know to know what the user has chosen or inputed.

davidism
  • 121,510
  • 29
  • 395
  • 339
Robert
  • 13
  • 1
  • 7

1 Answers1

0

As @John Gordon recommended, you could use a Javascript window.onselect OR window.onchange call when the user selects an element.

For example, https://jsfiddle.net/fnpv6cxf/ has the included method from the Mozilla Developer Guide for using onselect.

Using onchange: https://jsfiddle.net/fnpv6cxf/1/

Jeremy
  • 1,894
  • 2
  • 13
  • 22
  • isn't onselect for selecting text? I think you meant onchange – Kronen Jul 17 '17 at 20:36
  • @Kronen correct, I interpreted his request of "when a user clicks an element" to mean text, but it could be an `onchange` event as well. – Jeremy Jul 17 '17 at 20:38