Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
is there a way to make a popup input field for flask (and possibly js)?

I am trying to make a webpage using flask and html. at one point, I need a varible number of input fields, without reloading the page. I plan to do this by having a button that saying "add field", and when they click it, a new field pops up for them to type in. (this field will have a submit button, and will only take effect when they press the submit button, so they can leave it blank and not effect anything)

I couldnt find anything about adding popup fields in html or flask, but if ther is a way, I would love to know. instead, (and mabye temporarily), I have implamented some javascript into my html code. this javascript works, and creates a popup field, but when I try make a form variable to pass to the python page, it gives me an error. the page works fine, but the variable is not passed to the python page so that python can print it.

can anyone tell me a way to make a popup input field in flask and html and mabye javascript?

heres is the code im currently using:

python:


app = Flask(__name__)
app.config['SECRET_KEY'] = 'a_secret_key'#secret key

@app.route('/', methods=('GET', 'POST'))
def newroster():
    if request.method == 'POST':
        variable = request.form['test']
        print(variable)
        
    return render_template('test.html')

if __name__ == '__main__':
    app.run(debug=True)

html:

<html>
    <head>
        <title>Test</title>
        <script type = "text/javascript">           
            function buttonclick() {
                var iframe = document.createElement('iframe');
                var html = '<html><body><form method="post"><label for="test">Input Here</label><br><input type="text" name="test"placeholder="Input" value="{{ request.form['test']}}"></input><br><button class="button" type="submit" name="submit" value="submit">Submit</button></form></body></html>';
                iframe.src = 'data:text/html;charset=utf-8,' + encodeURI(html);
                document.body.appendChild(iframe);
                console.log('iframe.contentWindow =', iframe.contentWindow);                     
            }   
        </script>
    </head>
    <body>
        <input type="button" value="Click Me" onclick="buttonclick()">
    </body>
</html>
about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda