如何将 python if 语句添加到 html 中的 onchange 事件
How add python if statement to onchange event in html
你好
我的示例字符串 html 代码:
x = '''<input type="text" name="firstname">
<input type="text" name="firstname1">
<input type="text" name="firstname2">
<input type="text" name="txt" onchange="myFunction()">
<input type="submit" value="Submit">
<script>
function myFunction() {
''' --->python code--->if request.forms.get('txt'):
return x= "ok"
'''
}
</script>'''
我该怎么做?
所有这些都需要在提交之前发生
'''<input type="text" name="firstname">
<input type="text" name="firstname1">
<input type="text" name="firstname2">
<input type="text" name="txt" onchange="myFunction()">
<input type="submit" value="Submit">
<script>
function myFunction() {
{}
}
</script>'''.format(THE PYTHON CODE THAT EVALUATE TO TEXT)
你好
我的示例字符串 html 代码:
x = '''<input type="text" name="firstname">
<input type="text" name="firstname1">
<input type="text" name="firstname2">
<input type="text" name="txt" onchange="myFunction()">
<input type="submit" value="Submit">
<script>
function myFunction() {
''' --->python code--->if request.forms.get('txt'):
return x= "ok"
'''
}
</script>'''
我该怎么做?
所有这些都需要在提交之前发生
'''<input type="text" name="firstname">
<input type="text" name="firstname1">
<input type="text" name="firstname2">
<input type="text" name="txt" onchange="myFunction()">
<input type="submit" value="Submit">
<script>
function myFunction() {
{}
}
</script>'''.format(THE PYTHON CODE THAT EVALUATE TO TEXT)