Just

$('#Pais').change(function(){ ajax('Estado', ['Pais'],'target') });



On Nov 3, 11:40 am, Sophie <kfarron...@gmail.com> wrote:
> I sont unsertand the suggestion, something like this?
>
> $('#Pais').attr('onChange',  ajax('Estado', ['Pais'],'target'));
>
> and now
>
> $('#Pais').change(function(){ $('#Pais').attr('onChange',  ajax
> ('Estado', ['Pais'],'target'))
>
> On 3 nov, 10:48, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > I think it is because:
>
> > def city():
> >     state = request.vars.values()[0]
> >     city = db(db.city.idState == state).select()
> >     return SELECT(_id=city,_name=city,*[OPTION(city
> > [i].nCity, _value=str
> >     (city[i].id)) for i in range(len(city))])
>
> > should be
>
> > def city():
> >     state = request.vars.values()[0]
> >     city = db(db.city.idState == state).select()
> >     return SELECT(_id="city",_name="city",*[OPTION(city
> > [i].nCity, _value=str
> >     (city[i].id)) for i in range(len(city))])
>
> > I also suggest that you change
>
> > $(...).attr('onChange', f());
>
> > with
>
> > $(...).change(function(){ f(); });
>
> > On Nov 3, 9:23 am, Sophie <kfarron...@gmail.com> wrote:
>
> > > Hi all i have a problem with multi combo.
>
> > > I have three tables Country, State, City. The first time it works
> > > fine, i select a country (Canada), it appears the state combo, i
> > > select a state (Alberta), and appear the city combo. Here is working
> > > fine.
>
> > > My problem is the second time i want to select a country. I select
> > > anothe country (United States), the city combo dont dissapear and it
> > > still shows the cities of the Alberta state. the country combo
> > > actualizate, and when i selet a country the city combo appear with the
> > > correct data.
>
> > > So i want to hide the combo when i select another country, so i can
> > > dissapear the inconsistency, and when i select a state it shows again
> > > with the correct data.
> > > The other option is that i select a country and the city combo
> > > actualizates the citys of the country i select, i think this is more
> > > complicated than the first option.
>
> > > If you could help i would appreaciate it. Here is the code im using:
>
> > > Controller:
>
> > > def index():
> > >     country = db((db.state.idCountry==db.country.id)&
> > > (db.city.idState==db.state.id).select
> > > (db.country.ALL,  groupby=db.country.id)
> > >     return dict(country=country)
>
> > > def state():
> > >     country = request.vars.values()[0]
> > >     state = db(db.state.idCountry == country).select()
> > >     return SELECT(_id="state", _name="state",_type="select",
> > >         _onChange="ajax('"+URL(r=request,f=city)+"',['state'],
> > > 'target1');",
> > >         *[OPTION(state[i].nstate, _value=(state[i].id))
> > > for i in range(len(state))])
>
> > > def city():
> > >     state = request.vars.values()[0]
> > >     city = db(db.city.idState == state).select()
> > >     return SELECT(_id=city,_name=city,*[OPTION(city
> > > [i].nCity, _value=str
> > >     (city[i].id)) for i in range(len(city))])
>
> > > View:
>
> > > {{extend 'layout.html'}}
> > > <table>
> > >     <tr><div id="tar">
> > >     <select name="country" id="country" >
> > >         {{for x in country:}}
> > >             <option value={{=x.id}}>{{=x.nCountry}}</option>
> > >         {{pass}}
> > >     </select>
> > >     </div><tr>
> > >     <tr><div id="target"> <div> </tr>
> > >     <tr><div id="target1"> <div> </tr>
> > >     <tr><div id="target2"> <div> </tr>
> > > </table>
> > > <script>
> > > $(document).ready(function(){
> > >     $('#country).attr('onChange',  ajax('state',
> > > ['country'],'target'));
>
> > > ----------------------------------------------------------------------
> > > -------> Here i have the problem, the next line doesn't work
> > > ----------------------------------------------------------------------
> > >     $('#state).attr('onChange',  ajax('city',
> > > ['state'],'target1'));});
>
> > > $('#country).change(function(){
> > >     $('#country).attr('onChange',  ajax('state',
> > > ['country'],'target'))});
>
> > > </script>- Ocultar texto de la cita -
>
> > - Mostrar texto de la cita -
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to