jQuery solves this kind of problem quite nicely.
Punctuation and closing parends left as an exercise in this
example ;).
Spelling not guaranteed either.
The dollar sign = 'jquery'. Less typing.
Assuming you have a set of rows in your controller...
tbl = TABLE(THEAD(TH('name'), TH('What You Want To Update)...
for row in rows:
tbl.append(TR(
row.name,
INPUT(_type='text', _name=row.id, _id=row.id,
_class='myinput')
))
Then your form includes:
<input type="hidden" name="which_one" id="which_one">
<input type="hidden" name="how_much" id="how_much">
jQuery like so:
$('.myinput').live('click', function(e){
id = this.id
value = this.val; // or is it "this.value?"
$('#which_one').val(id);
$('#how_much').val(value);
ajax('process_it', ['which_one', 'how_much'], ':eval');
// caution: parends not closed
// usually this is wrapped by a call to $('document').ready( ...
Controller:
def process_it():
db(db.sometable.request.vars.which_one).update(
somefield=request.vars.how_much)
the_table=function_to_make_the_table()
out = '$("#the_div_where_the_table_lives").html("the_table")'
return out
On Dec 13, 4:38 pm, Anthony <[email protected]> wrote:
> On Tuesday, December 13, 2011 4:33:38 PM UTC-5, Richard wrote:
>
> > Hello Anthony,
>
> > Since my "row" come from a query may I can do something like this (pseudo
> > code) :
>
> > rows = db((db.lotns_lot_number.id == request.args(1))&\
> > (db.lotns_sample.lot_number_id == db.lotns_lot_number.id)&\
> > (db[request.args(0)].sample_id ==
> > db.lotns_sample.sample_id)).select\
> > (db[request.args(0)].ALL, *HASH_FUNC(db[request.args(0)].ALL)*
> > orderby=db.lotns_sample.sample_code)
>
> > In SQL it is pretty common to use Alias for computed field on the fly... I
> > just don't know if web2py can handle it that way...
>
> Maybe use a virtual field, which can be applied to a
> join:http://web2py.com/book/default/chapter/06#Virtual-Fields