Okay, I found the solution and post it here in case somebody else
needs it.
In my form definition I add some checkboxes, like this:
myform = form.Form(form.Checkbox("firstbox", description="firstbox",
value="firstbox"),
...
In my class I define:
def POST(self):
...
firstbox = form['firstbox'].checked
Now I can use it like this:
if firstbox:
# meaning: if the value of firstbox is true (checked)
...
else:
'none'
It works fine now
Mark
On 18 sep, 19:38, digistam <[email protected]> wrote:
> after some thoughts, maybe it is possible to use 'if statements',
> like:
>
> (pseudo code)
> if checkbox1 is checked:
> d = simplejson...
> if checkbox2 is ckecked:
> e = simplejson...
> etc.
>
> is it possible to use the form field values in the script?
> if so, what's the exact code to use, for example:
>
> if (checkbox.1 == checked):
> ...
>
> thanks again, really need your assistance here
>
> mark
>
> On 18 sep, 17:09, digistam <[email protected]> wrote:
>
>
>
>
>
>
>
> > I need some help with this:
> > I have one class which fills an array with several sources (json),
> > like this:
>
> > ******
> > class index:
> > def POST(self):
> > form = myform()
> > ...
> > twarray = [[],[],[],[],[],[],[],[],[],[],[],[],[]]
> > d = simplejson.load(urllib2.urlopen("first_url/earch.json etc. etc.)
> > for i in range(len(d['results'])):
> > twarray[0].append(value1 etc.)
> > ...
> > e = simplejson.load(urllib2.urlopen("second_url/earch.json etc. etc.)
> > for i in range(len(e['results'])):
> > twarray[0].append(value1 etc.)
> > ...
> > f = simplejson.load(urllib2.urlopen("third_url/earch.json etc. etc.)
> > for i in range(len(f['results'])):
> > twarray[0].append(value1 etc.)
> > ...
> > pages = dict([('field1',twarray[0]),('field2',twarray[1]), etc.
> > etc.)
>
> > return render.index(pages)
>
> > ******
> > I have a search form page, like this:
>
> > <form name="main" method="post">
>
> > $if not form.valid: <p class="error">Probeer opnieuw:</p>
>
> > <table border=0px>
>
> > <td align="left" valign="top">$:form.render()</td>
>
> > <td align="left" valign="middle">
>
> > <input type="submit" value="Zoeken" />
>
> > </td>
>
> > </table>
>
> > </form>
>
> > ********
> > My application works like a charm but I get too much results to handle
> > in a simple way. What I would like to have are checkboxes on the
> > search form page with which my users can define which sources they
> > want to search in, like this:
>
> > [X] source 1 [ ] source 2 [ ] source 3 [ ] source 4
>
> > If possible, the user can check multiple boxes to search in multiple
> > sources. I think I have to build some array or something like that,
> > but I'm stuck ...
>
> > What would be the right thing to do ?
>
> > Many thanks in advance,
>
> > Mark
--
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en.