Form sending error, Flask

There is form with two <input type=”submit”>. But when i’m sending it, second submit causes error. layout: <form action=”{{ url_for(‘index’) }}” method=”post”> <input type=”submit” name=”add” value=”Like”> <input type=”submit” name=”remove” value=”Dislike”> </form> main.py: … if request.method == ‘POST’: if request.form[‘add’]: return redirect(url_for(‘index’)) elif request.form[‘remove’]: return redirect(url_for(‘index’)) … First submit(add) works well, but second(remove)…: Bad Request The … Read more

Angular 2: formGroup expects a FormGroup instance. Please pass one in

I am creating a form in Angular 2. My goal is to get data from the API and pass it into the form for editing purposes. However, I am running into this error: EXCEPTION: Uncaught (in promise): Error: Error in ./EditPatientComponent class EditPatientComponent – inline template:1:10 caused by: formGroup expects a FormGroup instance. Please pass … Read more

How to edit a Rails serialized field in a form?

I have a data model in my Rails project that has a serialized field: class Widget < ActiveRecord::Base serialize :options end The options field can have variable data info. For example, here is the options field for one record from the fixtures file: options: query_id: 2 axis_y: ‘percent’ axis_x: ‘text’ units: ‘%’ css_class: ‘occupancy’ dom_hook: … Read more

Is there any benefit to adding accept-charset=”UTF-8″ to HTML forms, if the page is already in UTF-8?

For pages already specified (either by HTTP header, or by meta tag), to have a Content-Type with a UTF-8 charset… is there a benefit of adding accept-charset=”UTF-8″ to HTML forms? (I understand the accept-charset attribute is broken in IE for ISO-8859-1, but I haven’t heard of a problem with IE and UTF-8. I’m just asking … Read more

Getting an option text/value with JavaScript

Answer: var option_user_selection = element.options[element.selectedIndex].text I am trying to build a form that fills in a person’s order. <form name=”food_select”> <select name=”maincourse” onchange=”firstStep(this)”> <option>- select -</option> <option text=”breakfast”>breakfast</option> <option text=”lunch”>lunch</option> <option text=”dinner”>dinner</option> </select> </form> What I’m trying to do is send in the select object, pull the name and the text/value from the option menu … Read more

Calling Javascript from a html form

I am basing my question and example on Jason’s answer in this question I am trying to avoid using an eventListener, and just to call handleClick onsubmit, when the submit button is clicked. Absolutely nothing happens with the code I have. Why is handleClick not being called? <html> <head> <script type=”text/javascript”> function getRadioButtonValue(rbutton) { for … Read more

By event.target, how I know that it is checkbox or it is radio?

In my html: <input type=”checkbox” name=”select”> <input type=”radio” name=”select”> name property same due to some logical reason in my JS I write below code: $(‘input[type=”checkbox”],input[type=”radio”]’).on(“change”,function(event){ console.log(event.target.nodename); // on both cases it show “INPUT” } }); How I will know that I click on checkbox or radio button? Answer .nodeName gives the html tag used so … Read more