Apparently several people have the same problem.
Unfortunately, they all use PHP which apparently does some weird stuff.
I have some server code that looks like this:
@app.route("/place", methods=['GET', 'POST'])
def place():
names = request.form.getlist('name')
checks = request.form.getlist('checkboxes')
if request.form.get('Add Element'):
#return template with another form element and all the data
#return default template with N copies of the input
Now here's the problem - if I use radio buttons for my Yes/No (checked or not), I can't use getlist
, because they've all got the same name. Alternatively, I can't use checkboxes, because for some reason "they" decided that checkboxes shouldn't be sent with a "false" value.
This solution doesn't work:
<input id='testName' type='checkbox' value='Yes' name='testName'>
<input id='testNameHidden' type='hidden' value='No' name='testName'>
Because, then I have somewhere between 1-2x the number of elements I want.
I don't want to use Javascript, though I easily could - this will be an extremely low-use site (maybe 200-300 page views per month, tops, usually clustered together towards the end of month).
One possible solution I had was to use an `YesNo' - but this seems a bit on the clunky side. Unfortunately, I can't readily think of any other way (without javascript involved) to do what I need.
Am I stuck with the select
option?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…