First I have a form:
class TestForm(forms.Form):
name = forms.CharField( max_length=30 )
age = forms.CharField( max_length=30 )
Then in the views.py:
def Test_page(request):
form = TestForm()
variables = RequestContext(request, {
'form': form,
})
return render_to_response('Test.html', variables)
In the temlates file, I want to add a iframe and a submit button. When
the submit button was clicked, some word will appear in the iframe.
The following code is the Test.html:
<html>
<title>Test Result Page</title>
<head>
<script language="javascript">
function test(){
var iframe = document.getElementById
("test");
var d = iframe.contentDocument;
d.body.innerHTML = "This is a test";
}
</script>
</head>
<body>
<form id="submit-form" method="get" action=".">
Name:{{form.name}}
age: {{form.age}}
<iframe id="test" width="50%" height="100px"></iframe>
<input type="submit" onClick="test()" value="click" />
</form>
</body>
</html>
Now, the problem is that, when I clicked the submit button, the text
of "This is a test" will display in the iframe for one second, and
then disappear. Is there any one know what's wrong with my code?
thanks
min
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---