Hey @SP, my view is not not displaying anything at all, my link is not
displayed!! I was working on your example above, I dont know if i am
missing something.
On Sunday, February 10, 2019 at 3:24:38 PM UTC+2, sandeep patel wrote:
>
>
> @Mostwanted
> I think you can achieve this functionality by a couple of ways.
> One, you can store every clicks value in session but you can only store
> for the time being.
> Another way you can directly store every clicks values in DB.
> You can try this code
> #Model
>
> db.define_table('countclick',
> Field('clicks', 'integer', default=0),
> auth.signature
> )
>
> #Controller
>
> def countclick():
> items = db(db.countclick).select()
> return dict(items=items)
>
>
> def counter():
> item = db.countclick[request.vars.id]
> new_count = item.clicks + 1
> if item.update_record(clicks=new_count):
> print("Yes")
> else:
> print('N0')
> return "{}".format(new_count)
>
> #View
>
> {{extend 'layout.html'}}
>
> <input type="hidden" id="id" name="id" value="" />
>
> {{for item in items:}}
> <a id="{{=item.id}}"
> onclick="jQuery('#id').val('{{=item.id}}');
> ajax('{{=URL('default', 'counter')}}', ['id'], 'item{{=item.id}}');"
> href="#">Increment</a>
> <p >
>
> Count=<span id="item{{=item.id}}">{{=item.clicks}}</span>
> <span onclick="jQuery('#id').val('{{=item.id}}');
> ajax('{{=URL('default', 'counter')}}', ['id'],
> 'item{{=item.id}}');"></span>
> </p>
> {{pass}}
>
> For more information you can check here
> <http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#Voting-and-rating>
>
> Thanks
>
> SP
>
>
> On Sun, Feb 10, 2019 at 5:38 PM mostwanted <[email protected]
> <javascript:>> wrote:
>
>> I am trying achieve something but i don't know how, i have a page called
>> Link (default/link.html) that has a link called Increment
>> {{=A('Increment', _id="increment",_href=URL('default', 'value'))}}
>>
>> and a page called value (default/value.html) that has a variable (X),
>> what i want is to have (X) incremented by 1 every-time I click the link
>> Increment in the page Link, this value should only increase by 1 every-time
>> a user clicks Increment, the value should not go back to zero or the
>> default value even when the user shuts own the system. I don't have a code
>> sample for this obviously coz i couldn't implement it, i only have this as
>> an idea, if anyone understands how i could implement this please help out.
>>
>> Regards;
>>
>> Mostwanted
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.