On Tuesday, June 11, 2019 at 1:57:31 AM UTC-7, mostwanted wrote:
>
> Still doesn't give desired results, it only duplicates the *NO LISTINGS*
> statement!
>
What did you put where Massimaliano had "..."; that's where you have to
show the value.
<span>{{=jobs.info}}</span>
And to show the No Listing only once, I'd change things to
{{
letters=['Finance', 'Accountant']
found = False
for jobs in details:
if jobs.category in letters:
found = True
}}
<span>{{=jobs.info}}</span>
{{pass}}
{{if not found: }}
<span style="font-weight: bold; color: red;">NO LISTINGS!</span>
{{ pass }}
/dps
> On Tuesday, June 11, 2019 at 9:59:57 AM UTC+2, Massimiliano wrote:
>>
>> Your last if is out of the for loop.
>> Try this way (not tested )
>>
>> {{letters=['Finance', 'Accountant']
>> for jobs in details:
>> if jobs.category in letters:
>> }}
>> ...
>> {{ else: }}
>>
>> *<span style="font-weight: bold; color: red;">NO LISTINGS!</span>*
>>
>> {{ pass }}
>> {{ pass }}
>>
>>
>>
>> On Tue, Jun 11, 2019 at 9:04 AM mostwanted <[email protected]> wrote:
>>
>>> My task is very simple but its failing, I have some words in the
>>> database that i am comparing to a list of words in the view, if any of the
>>> words from the database matches those in the view all the details of that
>>> word from the database should be displayed in a div in the view but if no
>>> word from the database matches any word in the list from the view a message
>>> of *NO LISTINGS* should be displayed. The problem i am encountering is
>>> that now if there is a match, the word details as well as the* NO
>>> LISTINGS *message are both displayed but its supposed to be one or the
>>> other not both at the same time. I must be missing something or doing
>>> something wrong somewhere, if anyone can figure out my error please assist.
>>>
>>> *CODE*:
>>> <div id="tab-1" class="tab-content current">
>>> {{letters=['Finance', 'Accountant']
>>> for jobs in details:
>>> if jobs.category in letters:
>>> }}
>>> <div class="jobPosts">
>>> <img width="80px" src="{{=URL('download', args=jobs.logo)}}" /><br
>>> />
>>> Company: {{=jobs.company}}<br />
>>> Post: {{=jobs.post}}<br />
>>> Post Description: {{=jobs.post_description}}<br />
>>> <span style="color: red; font-weight: bold;">Closing Date:
>>> {{=jobs.expiry_date}}</span><br />
>>> </div><br />
>>> {{pass}}
>>> {{pass}}
>>>
>>>
>>> *{{if jobs.category not in letters:}} <span style="font-weight:
>>> bold; color: red;">NO LISTINGS!</span> {{pass}}*
>>> </div>
>>>
>>> Regards;
>>>
>>> Mostwanted
>>>
>>> --
>>> 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].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/web2py/34db1df5-9f8d-4413-a10d-52c4958f410c%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/web2py/34db1df5-9f8d-4413-a10d-52c4958f410c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Massimiliano
>>
>
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/867fa2ba-dc76-4aa2-bfe2-9942016c6ff8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.