On Aug24, 7:31pm, murray3 <[email protected]> wrote:
> is there a way to run some python db.update code in   a view by using
> the onclick event from the checkbox.
> At present the python code just runs, I put the "checker" in there to
> try and toggle it off until the onclick event obviously does not run
> the python code as is.
> help appreciated
> chrism
>
> <table width="100%" cellpadding="1" cellspacing="0" border="0"
> class="display" id="example">
>                         <thead>
>                         <tr>
>                         <th>Part 
> Name</th><th>Content</th><th>Number</th><th>Created On</
> th>
>                         </tr>
>                         </thead>
>                         <tfoot>
>                         <tr>
>                         <th>Part 
> Name</th><th>Content</th><th>Number</th><th>Created On</
> th>
>                         </tr>
>                         </tfoot>
>                         <tbody>
>                         {{for part in parts:}}
>                         {{checker=0}}
>                         <tr>
>                         <td>{{=part.part_name}}</td>
>                         <td>{{=part.part_content}}</td>
>                         <td>{{=part.part_number}}</td>
>                         <td>{{=part.timestamp.year}}</td>
>                         <td class="center"><input type="checkbox" 
> name="check_"
> value="{{part.id}}"                                   onclick="{{if not 
> checker==0:}}
> {{=db.prodj_refs.insert(prodj_id=prodj.id,part_id=part.id)}}
> {{pass}}"></td>
>                         </tr>
>                         {{pass}}
>                         {{checker=1}}
>                         {{pass}}
>                         </tbody>
>                         </table>

No, you can't do this. All the {{python code}} are executed BEFORE the
final pure html page is served to the browser. In other words, you
need to feed pure javascript for the onclick event.

Tips: Use "View->Source" of your browser to know what is actually fed
to the browser. Then you will get the idea.

Yours,
Iceberg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to