On Monday, March 9, 2015 at 9:53:42 AM UTC-7, Ron Chatterjee wrote:
>
> you need to do 
>
>
> {{response.files.append(URL('static','js/java_script_file_I_am_runnning.js))}}
>
> in web2py before ajax call layout.html
>
> and then use 
>
> <script>
>
> your function
>
> </script>
>
> Correct me if I am wrong. Someone?
>

That step is either unnecessary or already done for you, because I didn't 
have to do it. 


<DIV id="my_hats">
{{=LOAD(c='t_hats', f='t_hats2.load', target='my_hats', ajax=True)}}
    <span id="jsoffs">Javascript off?  <a href="t_hats2.html" id="jsoffa">Click 
here</a></span>
</DIV>

(If javascript is enabled, I set the span's visibility to 'hidden')

JQuery is covered in Chapter 11
<URL:http://www.web2py.com/books/default/chapter/29/11/jquery-and-ajax>
and LOAD() is covered in Chapter 12
<URL:http://www.web2py.com/books/default/chapter/29/12/
components-and-plugins#LOAD>


It's easy enough to use, even I figured it out  :-)

Here's an example where I arm a button:

 dis_str = CAT(dis_str,
                TT("        "),
                INPUT(_name="derby", _type="hidden", value=index),
                TAG.BUTTON('derby promotion t=%s' % index,
                           _type="button", _name="proms%d" % (index),
                           _value=addy,
                           _onclick='ajax("promotes.load", ["addy","hname", 
"derby"], "my_promotions")',
                           _style="visibility:collapse", _id="promst%d" % 
(index)),
                BR())

and eventually dis_str gets sent to the client to display.

/dps




> On Monday, March 9, 2015 at 12:12:47 PM UTC-4, Garry Smith wrote:
>>
>> Hi again after reading chapter 6,
>>
>> I have found what I'm looking for.
>> I did the following and got thre results I wanted.
>>
>> {{for r in row:}}
>> <p>{{=r.surname}}<p>
>>
>> {{pass}}
>>
>> One other question I would like to ask.
>>
>> web2py works a lot like codeigniter for php using MVC, does web2py let 
>> you use jquery to send  data using  json ajax back to the controllers.
>>
>> For example using:    <div 
>> id='tracks_selected'onclick='getTracks($album->track_id)  in the view.
>>
>> Then use the following jquery
>>
>>
>> function getTracks(id) {
>> $.post("/media/getTracks", { id:id },
>>     function(data){
>> $('#tracks').html(data);
>>     });
>> }-
>>
>> Which would go the a controller /media/tracks with the id number to be 
>> processes in the controller?
>>
>>     
>>
>> On Monday, 9 March 2015 13:56:38 UTC, Garry Smith wrote:
>>>
>>> Hi Thanks for the reply,
>>>
>>> I have got query 2 working with the following:-
>>>
>>> qry = request.vars.upn_no
>>> q = (db.pupils.upn_no == qry)
>>> s = db(q) 
>>> row = s.select(db.pupils.upn_no,db.pupils.surname)
>>>
>>> which gives me the following.
>>>
>>> pupils.upn_no pupils.surname
>>>
>>> 5555                Dalglish
>>>
>>> Once in the view is their a way off changing column headings and just 
>>> showing what you want from the db.
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Monday, 9 March 2015 13:48:17 UTC, Jim S wrote:
>>>>
>>>> thelist=[row.first_name for row in db(db.user.upn == 444).select()]
>>>>
>>>> Have you read chapter 6 from the book?  It is well worth your time and 
>>>> should help with most of your questions.  
>>>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer
>>>>
>>>> -Jim
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Monday, March 9, 2015 at 8:31:13 AM UTC-5, Garry Smith wrote:
>>>>>
>>>>> I'm new to web2py, but do have a php and mysql background using 
>>>>> codeigniter.
>>>>> I'm trying to write a couple of queries but sure how to do them.
>>>>> These are the queries I'm trying to write,
>>>>>
>>>>> query1
>>>>>
>>>>> SELECT user.s_name, user.f_name, user.year, pe.date, pe.sport, pe.id
>>>>> FROM user
>>>>> INNER JOIN pe
>>>>> ON user.user_id=pe.user_id
>>>>> WHERE pe.date = DATE(NOW())
>>>>> ORDER BY user.year"
>>>>>
>>>>> query 2
>>>>>
>>>>> SELECT user.upn, user.f_name, user.s_name where user.upn = '4444'
>>>>>
>>>>>  I tried this on the second query,
>>>>> thelist=[row.first_name for row in db().select(db.pupils.first_name, 
>>>>> db.pupils.upn')]
>>>>>
>>>>> which pulls all records, need to know where to put  " where upn = 
>>>>> '4444'"
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>>
>>>>>
>>>>>

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