You'll have to be a little more specific than "doesn't work." What happens? What have you done to diagnose the problem? Does the ajax call get made properly? Etc.
#model > db.define_table('content', > Field('username'), > Field('text', 'text'), > Field('file', 'upload'), > Field('userpic'), > Field('time', 'datetime', update=request.now), > Field('userid', readable=False), > Field('votesup', 'integer', default=0), > Field('votesdown', 'integer', default=0), > Field('votes', 'text', default='0,'), > ) > You might instead consider creating a separate table to store the votes (with association to the user), but if you want to store the user ID's in a single field, you should at least be using the list:integer or list:reference field type instead of just a plain text field that you have to parse yourself. > > #controller > def voteup(): > item = db.content[request.args(0)] > if auth.user.id not in item.votes: > item.votes.join(str(auth.user.id)+',') > new_votes = item.votesup + 1 > item.update_record(votesup=new_votes) > return str(new_votes) > elif auth.user.id in item.votes: > return str(0) > When the user has already voted, why not return item.votesup (i.e., the current number of votes) rather than 0? > > #view > <button style='margin-left:30px; margin-top:-17px;'> > <span onclick="jQuery('#content_votesup').val('{{=content.id}}'); > What is the '#content_votesup' element, and why are you setting its value? > ajax('{{=URL('voteup', args=content.id)}}', ['votesup'], 'content0{{= > content.id}}');" > > Why do you specify a 'votesup' input in the Ajax call -- is there one? If so, your function doesn't use it (you appear to be passing the ID via the URL args). If you don't have any input elements to read, just pass an empty [] as the second argument. Anthony -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.