Without playing with your code too much, it's probably because your
"onsubmit" function doesn't return "false".

In normal javascript actions, on{event name} events are canceled by
returning false.  For example:

<script>
function test() {
    return confirm('are you sure?');
}
</script>

<a href="/example" onclick="test()">click me</a>

If you click on that link, it will only redirect if you select "Ok"
from the confirm dialog.  The onsubmit event listener works the same
way - you need to return false, or at the end of executing the
javascript code, it will submit the form.

Hope this helps!
-Justin

On May 11, 11:47 pm, globalrev <[EMAIL PROTECTED]> wrote:
> running the html-site by itself works fine but when im running it from
> webpy and click translate it redirects to a new site.
>
> why and how do i stop this?
>
> import web
> import rob
>
> render = web.template.render('templates/')
>
> urls = (
>   '/', 'main',
>   )
>
> class main:
>     def GET(self):
>         print render.main()
>
> ##    def POST(self):
> ##        i = web.input()
> ##        print rob.encrypt(i.enc)
> ##        if i.encdec == "encrypt":
> ##            print rob.encrypt(i.enc)
> ##        else:
> ##            print rob.decrypt(i.enc)
>
> web.webapi.internalerror = web.debugerror
> if __name__ == "__main__": web.run(urls, globals())
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> TR/html4/strict.dtd">
> <html>
> <head>
>
> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
>
> <title>robber's language</title>
> <style type="text/css">
> <!--
> body {
>   margin: 0px;
>   padding: 0px;}
>
> #header {
>   background: #FDD017;
>   width: 100%;
>   height: 10%;
>   font-size: xx-large;
>   text-align: center;}
>
> #content {
>   background: white;
>   float: right;
>   width: 100%;
>   height: 90%;
>   text-align: center;}
>
> a:link {color: black; }
> a:visited {color: white; }
> a:hover {color: black; }
> a:active {color: black; }
> -->
> </style>
> </head>
> <body>
>
> <div id="header">
>         <b>Robber's language encrypter/decrypter</b>
> </div>
>
> <div id="content">
>
>     <form action="..." onsubmit="return handleSubmit(this)">
>     <script type="text/javascript">
>       function handleSubmit(f)
>       {
>         f.elements['target'].value = f.elements['source'].value;
>       }
>     </script>
>     <div><textarea name="source" cols="60" rows="10"></textarea></div>
>     <div><input type="submit" value="translate"></div>
>     <div><textarea name="target" cols="60" rows="10"></textarea></div>
>   </form>
>
> </div>
>
> </body>
> </html>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to