[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
h.. Seems that I need to return js code lines (not js function) from controller & get going ahead. btw, I have found one line jquery code for selecting value of select box. "$('#element_id option[value=%s]').attr('selected', 'selected');" % adict['key'] Thanks for your responses Anthony. ---

[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
h.. Seems that I need to return js code from controller. btw, I have found a one-line jquery code for this--> "$('#element_id option[value=%s]').attr('selected', 'selected');" % dict_obj['key'] This works & I will proceed with this, for time being. Thanks for your responses Anthony. --- Vine

[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Anthony
I think you need .options[i] rather than .options(i). Anyway, it's generally easier to do this kind of thing with jQuery rather than raw Javascript. Anthony On Tuesday, November 8, 2011 9:04:41 AM UTC-5, Vineet wrote: > > Something is wrong in the function. > I defined a test js function in Vi

[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
I checked the js returned from controller function. It is selbx('edit_freq','daily'); selbx function is there in the View. -- Vineet On Nov 8, 7:04 pm, Vineet wrote: > Something is wrong in the function. > I defined a test js function in View. > > function alrt(mesg) { > alert(mesg) }; > >

[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
Something is wrong in the function. I defined a test js function in View. function alrt(mesg) { alert(mesg) }; And in Controller, return "alrt('Hello World!');" It works. The actual js function is--- (it sees which value of select box matches the one returned from controller; then sets the valu

[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 8:17:41 AM UTC-5, Vineet wrote: > > > If 'myvar' is a Python variable, you're going > > 'myvar' is a not a python variable. > I pass the id of html element as argument. > Javascript code sets the value of that html element. OK, but same problem -- 'myvar1' isn't a

[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
> Probably a typo, but missing the closing single quote (') after the }} for > the URL. It is a typo here. It is correct in actual code. > If 'myvar' is a Python variable, you're going 'myvar' is a not a python variable. I pass the id of html element as argument. Javascript code sets the value o

[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 7:45:59 AM UTC-5, Vineet wrote: > > In a View, there is --> ajax('{{=URL("salhead_edit")}}, [], > ':eval'); > Probably a typo, but missing the closing single quote (') after the }} for the URL. > "salhead_edit" returns js function --> 'abc(myvar1)' > Unless 'm