我有一个python文件有效性.py. 在那个文件里我有以下内容功能:在
def login():
return '''
<body bgcolor="#FFDEAD">
<form action="/login" method="post">
<img src='http://%s:%s/login/guavusLogo.png'>
<h1>Validity</h1><br>
<h2> Configuration Parameters</h2><br>
<table>
<tr>
<tr><td><lable>Chose from the following</td><td> <select name="options">
<option value="unhide">unhide</option>
<option value="hide">hide</option>
</select></td><tr>
<td>Start Date: </td><td><input name="startDate" type="text" /></td></tr>
<tr><td>End Date:</td><td> <input name="endDate" type="text" /></td></tr>
</table>
<input value="Submit" type="submit" />
</form>
<script src="http://code.jquery.com/jquery-1.9.1.min.js">
$("select").change(function() {
if ($("select option:selected")[0].value == 'unhide') {
$("[name='startDate']").show();
$("[name='endDate']").show();
}
else {
$("[name='startDate']").hide();
$("[name='endDate']").hide();
}
});
</script>
<script type="text/javascript" src="%s:%s/login/validate.min.js"></script>
</body>
''' %(host,port,host,port)
def yes():
...
...
do something
...
...
def no():
...
...
do something
...
...
def do_login():
startDate = request.forms.get('startDate')
endDate = request.forms.get('endDate')
callOptions = request.forms.get('options')
paramList = [startDate, endDate, callOptions]
if '' in paramList or None in paramList:
return "<p>Insufficient Arguments Entered. Please enter all the arguments mentioned in the config page</p>"
else:
if callOptions == "yes":
yes()
elif callOptions == "no":
no()
run(host=host, port=port, debug=True)
do_login()
不要担心我如何将网页带到服务器上,因为所有这些都已经处理好了。我希望当我在服务器上加载页面时,如果从下拉框中选择了“否”,我希望文本字段startTime和endTime隐藏起来;如果选择了“是”,则取消隐藏它们。在
所以在do\u login()函数中,我把if条件设为if callOptions==“no”,然后它调用指定的函数,但我希望文本字段隐藏起来,反之亦然。在
有什么帮助吗? 谢谢
使用jquery(您似乎已经在使用它),您可以在客户机上执行此操作,而不需要任何服务器端处理。在
这应该可以在不更改HTML的情况下工作:
另外,它应该是},您应该关闭该标记。在
<label>
,而不是{相关问题 更多 >
编程相关推荐