나는 Webpy를 처음 사용합니다. 현재 Dropdown 메뉴에서 선택한 항목을 검색하는 데 어려움이 있으며 어떤 도움도받지 못했습니다. 누구든지 문제를 해결하는 방법을 보여줄 수 있습니까?Webpy 드롭 다운에서 선택한 항목을 얻는 방법
감사
내 파이썬 서버
:import web
import pdb
from matching_tester import *
def make_text(string):
return string
class tutorial:
def GET(self):
form = my_form()
return render.tutorial(my_form(), "Your text goes here.")
def POST(self):
form = my_form()
form.validates()
s = form.d.Devices
print s
return make_text(s)
if __name__ == '__main__':
urls = ('/', 'tutorial')
render = web.template.render('templates/')
app = web.application(urls, globals())
my_form = web.form.Form(
web.form.Dropdown('Devices', [('1', 'iPhone 4'),
('2', 'iPhone 4S'),
('3', 'iPhone 5')],
web.form.notnull,
**{'multiple':None, 'size': 4}),
web.form.Dropdown('Country', [('1', 'All'),
('2', 'US'),
('3', 'JP')],
web.form.notnull,
**{'multiple':None, 'size': 4})
)
app.run()
내 HTML :
=== tutorial.html ===
$def with (form, text)
<!doctype html>
<html>
<head>
<title>Python and AJAX tutorial for beginners with webpy and jQuery</title>
<link rel="stylesheet" type="text/css" href="/static/tutorial.css" />
<script type="text/javascript" src="/static/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".button").click(function() {
var input_string = $$("input#textfield").val();
jQuery.ajax({
type: "POST",
data: {textfield : input_string},
success: function(data) { jQuery('#foo').html(data).hide().fadeIn(1500);
},
});
return false;
});
});
</script>
</head>
<body>
<br>
<form class="form" method="post">
$:form.render()
<input class="button" type="submit" value="send"/>
</form>
<br><br>
<span id="foo">$text</span>
</form>
</body>
</html>
내가 선택한 것은 인쇄물이 아닙니다. –