Actually SELECT tag in the controller has some predefined attributes. If we
want to specify any other html attributes, we need to specify them as
_attibutename = "attribute value". This code is translated into html code as
follows
<TAGNAME attributeame = attribute value> i.e., if there are any functions
specified as attribute value, those functions will not be executed but they
will literally be specified as the value in the html code. For the present
scenario,
SELECT("Andhra Pradesh","Delhi","Tamil Nadu",_name="state",
_id="States",default="Andhra
Pradesh",_onchange="ajax('{{=URL(r=request,f='getcities')}}',
['States'],'handle')",requires=[IS_NOT_EMPTY()]))
whill be translated to
<select name="state" id="States", default="Andhra Pradesh",
*onchange="ajax('{{=URL(r=request,f='getcities')}}',
['States'],'handle')"*>
<option>Andhra Pradesh</option>
<option>Delhi</option>
<option>TamilNadu</option>
</select>
In HTML, URL function doesnt exist and hence will not be executed and hence
the error. Hope I conveyed the message clearly :).
On Tue, Apr 28, 2009 at 11:12 PM, Yarko Tymciurak <[email protected]> wrote:
> say more about this.... ".... URL function was not working in the
> controller...."
> What was going on?
>
>
> On Tue, Apr 28, 2009 at 4:10 AM, Nithin Kumar M <[email protected]>wrote:
>
>> 10x for your kind replies...By using firebug debugger, I was able to solve
>> the problem. When I used {{= URL(r=request,f='getcities')}}, the URL
>> function was not working in the controller. And hence I had to give the
>> absolute path to solve the problem.
>>
>> regards,
>> Nithin Kumar M.
>>
>>
>>
>> On Sat, Apr 25, 2009 at 1:35 AM, mdipierro <[email protected]>wrote:
>>
>>>
>>> In this line
>>>
>>> $.ajax({type: "POST", url: u, data: query, success: function(msg)
>>>
>>>
>>> what is u?
>>>
>>> On Apr 24, 1:11 am, Nazgi <[email protected]> wrote:
>>> > Hi,
>>> >
>>> > I'm new to web2py. Can some1 tell me how to debug javascript
>>> > code in web2py? I've written the following code and am not able to
>>> > debug it...can some1 help me out plz...
>>> >
>>> > in controllers/identity.py
>>> >
>>> > def getcities():
>>> > citystr = request.vars.values()[0]
>>> > output = "<h1>Nizamabad</h1>"
>>> > if int(citystr) == 1:
>>> > output = "<h1>Hyderabad</h1>"
>>> > elif int(citystr) == 2:
>>> > output = "<h1>Chennai</h1>"
>>> > elif int(citystr) == 3:
>>> > output = "<h1>Pune</h1>"
>>> > return output
>>> >
>>> > def index():
>>> > form=FORM(TABLE(
>>> > TR("State:",\
>>> > SELECT("Andhra Pradesh","Delhi","Tamil
>>> > Nadu",_name="state", _id="States",default="Andhra
>>> > Pradesh",_onchange="ajax('{{=URL(r=request,f='getcities')}}',
>>> > ['States'],'handle')",requires=[IS_NOT_EMPTY()])),\
>>> > TR(DIV(_id="handle"))))
>>> > return dict(form=form)
>>> >
>>> > in identity/index.html
>>> >
>>> > {{extend 'layout.html'}}
>>> > <script type="text/javascript"><!--
>>> > function myajax(u,s,t) {
>>> > var query="";
>>> > for(i=0; i<s.length; i++) { if(i>0) query=query+"&";
>>> > query=query+encodeURIComponent(s[i])+"="+encodeURIComponent
>>> > (document.getElementById(s[i]).value);
>>> > }
>>> > $.ajax({type: "POST", url: u, data: query, success: function(msg)
>>> > { document.getElementById(t).value=msg; } });}
>>> >
>>> > //--></script>
>>> > <div = "content">
>>> > <div id="flash">{{=response.flash}}</div>
>>> > <h2>Register</h2>
>>> >
>>> > {{=form}}
>>> > </div>
>>> >
>>> > I'm not able to pick where the connection is lost. Is my ajax function
>>> > working and communicating with getcities method or is it the wrong way
>>> > to write the handle function?
>>> >
>>> > Its really a urgent thing for me. Please help me out. Thanks in
>>> > advance...
>>>
>>>
>>
>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---