On Monday, February 29, 2016 at 6:06:08 PM UTC-8, Ron Chatterjee wrote:
>
> {{for i in range(0,len(post)):}}
>
> <form enctype="multipart/form-data" action="{{=URL('save_post')}}" 
> method="post">
>
>     <td><input type="checkbox" name="name" value= 'on' /></td>
>

How are you choosing name here?
 

>     
>     <td>{{=post[i].created_by}}</td>
>     <td>{{=post[i].body}}</td>
>
> {{pass}}
>
> <input type="submit" />
> </form>
>
>
> If I click on the checkbox. My request.args.name is 'on'. If I don't 
> click its empty. Nice. But how do I pass the post[i].id
> argument to save_post based on which id was checked? Does the value 
> parameter takes an integer value. because value = {{i}} doesn't work
>

I think you're supposed to encode the value "i" into the name. 

I do something like this in one of my controllers:
           [...]
           for index in range(0, count):
               CAT(display, TAG.BUTTON('get summary t=%s' % index,
                           _type="button", _name="summ%d" % (index),
                           _value=myValue,
                           _onclick="$('#my_stuff').html('" + loading_str + 
"');" +
                                    'ajax("summary.load", ["var1", "var2"], 
"my_div")',
                           _style="visibility:collapse", _id="summt%d" % 
(index)))
           # endfor

The controller is set up to send a giant HTML string to the view (var name 
"display").  The main view file for the page has 

<DIV id="my_div">
    </DIV>


The inner view file summary.load doesn't have much more than
<h3>
    {{=hd1}}
</h3>
{{=PRE(display)}}


Of course, this isn't a good example of MVC construction because I do so 
much formatting in the controller, but perhaps it will give you ideas of 
how to do things in your setup.  Moving the button loop to the view should 
work for most projects.

(I do so much in the controller because I'm reading binary buffers 
containing data sent by a remote device, and I got lazy about making a huge 
dictionary to use to fill in the view.  Recently I made a copy of this 
procedure, and morphed it to produce json strings, which I suppose I could 
use as a huge dictionary to fill in the view.)

/dps

-- 
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.

Reply via email to