If I use Onclick="submit();", how to add the javascript function " test ()" to that buttom?
thanks On Feb 2, 11:58 am, "Will Matos" <w...@tcdi.com> wrote: > Onclick="submit();" > Will Matos > TCDI > Director of Technical Sales > 4510 Weybridge Lane > Greensboro, NC 27407 > 336.232.5832 office > 336.232.5850 fax > 336.414.0467 mobile > > > > ----- Original Message ----- > From: django-users@googlegroups.com <django-users@googlegroups.com> > To: Django users <django-users@googlegroups.com> > Sent: Sun Feb 01 19:52:49 2009 > Subject: Re: trouble with Django and javascript > > Thanks for you reply. > > However, if I change the 'submit' to button, how can I submit the form > to the server? > > Regards > min > > On Feb 2, 11:34 am, "Todd O'Bryan" <toddobr...@gmail.com> wrote: > > In addition to displaying the message, it's also submitting the form, > > so you see the text for a second and then the form reloads. > > > Change the <input type="button" ...> instead of "submit" and see if that > > helps. > > > Todd > > > On Sun, Feb 1, 2009 at 6:05 PM, min <inuyasha...@gmail.com> wrote: > > > > 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 django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---