Perhaps there is a way to get different variable values depending on
what address you load??? For example:
http:.......default/index.html...something...n=1,m=0

On Dec 18, 4:07 am, Luther Goh Lu Feng <elf...@yahoo.com> wrote:
> You can use javascript or jquery(since web2py includes jquery) to do
> this:
>
> ==javascript==
> $('#some_id).click(function()
>   {
>      $('#target").val( ($('#target").val()+1) );
>   }
> )
>
> ==html==
> <span id="some_id"<a href="#"> Click me</a></span>
>
> <span id="target">2</span>
>
> This should more or less work.
>
> On Dec 18, 10:02 am, Rick <sababa.sab...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Thanks for the replies! The variable that I'm operating with is python
> > type, not javascript. Mdipierro, your solution looks nice, but i can't
> > get it working. The value of the variable doesn't seem to change. Here
> > is my code:
>
> > from views/default/index.html:
> > {{n=1}}
> > <a href="#" onclick="ajax('{{=URL('plus_n')}}',[],':eval');return
> > false">plus</a>
> > {{=n}}
>
> > controller.py
> > def plus_n():
> >     # check this was called by the ajax post
> >     if request.env.request_method=='POST':
> >         # do anything you need to do
> >         session.n=session.n+1
> >         # optional return instructions in JS
> >         return "$('.flash').html('n was incremented').slideDown();"
>
> > On Dec 18, 2:26 am, pbreit <pbreitenb...@gmail.com> wrote:
>
> > > I don't really understand the question. Do you want to change a JavaScript
> > > variable? Or a variable in your web2py code? I don't think you would be 
> > > able
> > > to modify a web2py variable as the result of a click. By the time the suer
> > > views your page, all the web2py code has been rendered into HTML. You'll
> > > either need to code some JavaScript or perform some sort of Ajax call back
> > > to your server.
>
> > > What exactly are you trying to do?

Reply via email to