Skip to content Skip to sidebar Skip to footer

Sending Data From A Html Non-input To Flask

how can i send non-input data (like lists) from html to Flask. with request.from i only receive the button informations in python, but i want the data from the list. What i have

Solution 1:

HTML forms only send along <input> tagged values to the remote endpoint when a "submit" input is pressed. You have three list elements, but only one "input" element - the submit button.

Try putting the other elements you want to be sent up with the form in "input" tags, with appropriate types, and 'name' attributes identifying how the values will be extracted in processing code:

<formaction="/"method="POST"><ulclass="list-group"><liclass="list-group-item"><selectname="my_select"><!-- *NOTE* the select field, with options in a dropdown --><optionvalue="val1">Value 1</option><optionvalue="val1">Value 2</option><optionvalue="val1">Value 3</option></select></li><liclass="list-group-item"><inputtype="text"name="data_2"placeholder="Data that I want to receive 2"></input></li><liclass="list-group-item"><inputtype="text"name="data_3"placeholder="Data that I want to receive 3"></input></li><liclass="list-group-item"><inputname="send"type="submit"value="Send"></input></li></ul>

The tag you're probably looking for to achieve your 'list' goal is 'select'. Select has 'option' children that are the available choices from a dropdown list.

There are other input types than "text"; see https://www.w3schools.com/html/html_forms.asp for a concise basic rundown of how HTML forms work.

Edit: cleaned up some formatting; added placeholder value, added list dropdown after re-reading OP question.

Post a Comment for "Sending Data From A Html Non-input To Flask"