【问题标题】:How add python if statement to onchange event in html如何将python if语句添加到html中的onchange事件
【发布时间】:2018-07-11 23:50:25
【问题描述】:

你好

我的带有 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>'''

我该怎么做?

所有这些事情都需要在提交之前发生

【问题讨论】:

  • 您不能为此使用 Python。使用 Javascript。

标签: python html bottle


【解决方案1】:
'''<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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-16
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    • 2012-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多