Don't take it in the wrong way, I'll start with a little introduction: 
web2py is a framework that can do a lot of stuff. When it generates an HTML 
page the way you told him so, it returns it to the browser. From then on, 
it's just how HTML works: any button (without javascript intercepting the 
click event) included a form submits the form it's included in.

Given that you need to call a page instead of submitting the form, why 
don't you use a simple link (A()) ? 
If you need to use a button for some obscure reason to call a page, either 
you generate it OUTSIDE the form, i.e.

...
<form .... >

</form>
<button .....</button>
....
so it won't trigger the form submission, or you intercept the click in 
javascript. 
If you want to use the onclick attribute, the shortest route is including 
"return false" in the javascript bit attached to it. There are more 
elaborate and correct ways to do it but you must learn javascript first.

It's quite pathetic that web2py doesn't provide a BUTTON helper by the 
> way...
>

Please, show us with some code of what you wish for. 

>>> BUTTON()
<gluon.html.BUTTON object at 0x17a4f50>
>>> BUTTON().xml()
'<button></button>'
>>> BUTTON('Hello World').xml()
'<button>Hello World</button>'
>>> BUTTON('Hello World', _onclick="whatever").xml()
'<button onclick="whatever">Hello World</button>'
>>> BUTTON('Hello World', _onclick="whatever", _href=URL('default', 'index'
)).xml()
'<button href="/examples/default/index" onclick="whatever">Hello 
World</button>'
>>> BUTTON('Hello World', _onclick="whatever", _href=URL('default', 'index'
), _type="submit").xml()
'<button href="/examples/default/index" onclick="whatever" 
type="submit">Hello World</button>'
>>> BUTTON('Hello World', _onclick="whatever", _href=URL('default', 'index'
), _type="submit", _class="whateverclass").xml()
'<button class="whateverclass" href="/examples/default/index" 
onclick="whatever" type="submit">Hello World</button>'
>>> BUTTON('Hello World', _onclick="whatever", callback=URL('default', 
'index'), _type="submit", _class="whateverclass").xml()
'<button class="whateverclass" onclick="whatever" type="submit">Hello 
World</button>'



 

-- 



Reply via email to