Jump to content
Fórum Script Brasil
  • 0

Selecionar TODOS os dados da tabela para um campo


Question

Preciso alterar um arquivo, e selecionar todos os dados de uma tabela.

Quando eu seleciono estados por exemplo, ele abre as cidades por estado que escolhi, e tenho que selecionar apenas uma cidade.. Mas eu quero ao selecionar um estado,  SELECIONAR TODAS AS CIDADES do estado que eu selecionar, e NÃO de selecionar apenas uma cidade.

 

Segue script

 

<div class="head">
    <span id="title" style="color:black;">{l_choose_a_city}</span>
    <a id="choose_city_close" class="icon_close" href=""></a>
</div>
<div class="cont">
    <ol id="selectable">
        {list_options}
    </ol>
</div>
<div class="foot">
    <a id="back_item" data-type="" class="back" href="#">{l_back_to_states}</a>
    <input id="choose_ok" type="button" class="btn blue fl_right" value="{l_ok}" />
</div>
<script>
var param = ['geo_countries', 'geo_states', 'geo_cities'],
    param_geo = ['{country_id}', '{state_id}', '{city_id}'],
    param_list = ['', '', '{list_options_js}'],
    param_geo_set,
    param_list_set,
    title_back = ['{l_back_to_countries}', '{l_back_to_states}'],
    title = ['{l_choose_a_country}', '{l_choose_a_state}', '{l_choose_a_city}'];
    pp_choose_city = $('#pp_choose_city'),
    selectable = $('#selectable'),
    selectable_li = $('#selectable li'),
    back_item = $('#back_item'),
    title_head = $('#title'),
    choose_ok = $('#choose_ok'),
    step = 2,
    title_city = '',
    searchFilter=$('#filter_module_location_title'),
    isSearchFilter=searchFilter[0]?1:0,
    userNoCity = '{user_no_city}',
    opt=.6;

    if(typeof param_geo_init != 'undefined') {
        param_geo = param_geo_init;
    }

    param_geo_set = param_geo.concat();
    param_list_set = param_list.concat();

    selectable.scrollTo('#{selected_options}');

    $('.profile_city_choose').click(function(){
        setCountry();return false;
    });

    $('#choose_city_close').click(function(){
        pp_choose_city.close();return false;
    });

    choose_ok.click(function (){
        pp_choose_city.close();
        if (param_geo_set[2] != param_geo[2] || (userNoCity*1 && !isSearchFilter)) {
            userNoCity = 0;
            param_geo_set = param_geo;
            param_list_set = param_list;
            title_city = $('#selectable li.selected').text();

            // search page filter
            var filter=$('#filter_module_location_title');
            if(filter[0]) {
                filter.text(title_city);
                $('.find_new_friends_in_city_now').html(tmplCityTitle.replace('\{city\}', title_city));
                $('#filter_country').val(param_geo[0]);
                $('#filter_state').val(param_geo[1]);
                $('#filter_city').val(param_geo[2]);

                if(filterCityValue != param_geo[2]) {
                    filterCityValue = param_geo[2];
                    $(moduleFilterClass).change();
                }

                return false;
            }

            $.post('{url_main}ajax.php', {cmd: 'geo_param_map', country: param_geo[0], state: param_geo[1], city: param_geo[2]}, geo_map);
            //$('#selectable li').off('click');
            //pp_choose_city.remove();
        }
        return false;
    });

    $('.pp_body').on('click', function(e){
        if(e.target==this
           &&$('#pp_choose_city:visible')[0]
           &&param_geo_set[2]==param_geo[2]){
            pp_choose_city.close()
        }
    })

    function geo_map(res)
    {
        var data=checkDataAjax(res);
        if(data){
            var map=$('#map_title'),filter=$('#filter_module_location_title');
            if(map[0]){
                map.text(title_city+', '+data.country);
                load_map(data.lat/{ip_multiplicator}, data.long/{ip_multiplicator});
            }
        }else{}
    }

    function load_map(lat, long)
    {
        var pic = new Image(),
            map = $('#profile_map');
            src = "http://maps.googleapis.com/maps/api/staticmap?markers=color:red%7Clabel:%7C"+lat+","+long+"&center="+lat+","+long+"&zoom=10&size=459x277&sensor=false&scale=1";;
        map.attr('src', '{url_tmpl_main}images/airplane.gif');
        pic.src = src;

        var mapBox = $('#profile_map_box'),
            isHideMap = parseInt(mapBox.css('height')) == 0,
            dur = (isHideMap) ? 1 : 1600;
        $(pic).load(function(){
            map.hide().attr('src', src).fadeIn(dur,function(){
                if (isHideMap) {
                    mapBox.animate({height:'277px'},300);
                }
            });
        });
    }

    function setCountry()
    {
        step=2;
        delete param_geo;
        delete param_list;
        param_geo = param_geo_set.concat();
        param_list = param_list_set.concat();

        title_head.text(title[2]);
        back_item.html(title_back[1]).show();
        $('#'+param_geo[2]).addClass('selected').siblings().removeClass('selected');
        selectable.html(param_list[2]).scrollTo('#'+param_geo[2]);
        choose_ok.hide();
        choose_ok.show();

        pp_choose_city.open();
    }

    back_item.click(function(){
        var select_id, list;
        if (step == 1) {
            back_item.hide();
        }
        selected = param_geo[step-1];
        select_id = (step>1) ? param_geo[step-2] : param_geo[0];
        list = param_list[step-1];
        choose_ok.hide();
        if (list != '') {
            step--;
            selectable.html(param_list[step]).scrollTo('#'+param_geo[step]);
            back_item.html(title_back[step-1]);
            title_head.text(title[step]);
        } else {
            selectable.fadeTo(0,opt);
            $.post('{url_main}ajax.php', {cmd: param[step-1], select_id: select_id, selected: selected, filter:isSearchFilter}, update_list_back);
        }
        return false;
    })

    var update_list_back = function(res)
    {
        var data=checkDataAjax(res);
        if(data){
            step--;
            param_list[step] = data.list;
            selectable.html(data.list).fadeTo(0,1).scrollTo('#'+param_geo[step]);
            back_item.html(title_back[step-1]);
            title_head.text(title[step]);
        }else{}
    }

    $('body').on('click', '#selectable li', change);

    function change(){
        var select_id = $(this).attr('id');
        $(this).addClass('selected').siblings().removeClass('selected');
        param_list[step] = selectable.html();
        back_item.html(title_back[step]).show();
        title_head.text(title[step+1]);
        if (step == 2) {
            param_geo[step] = select_id;
            choose_ok.show();
        } else {
            if (param_geo[step] != select_id) {
                param_geo[step] = select_id;
                selectable.fadeTo(0,opt);
                $.post('{url_main}ajax.php', {cmd: param[step+1], select_id: select_id, filter:isSearchFilter}, update_list);
            } else {
                step++;
                selectable.html(param_list[step]).scrollTo('#'+param_geo[step]);
            }
        }
    }

    var update_list = function(res)
    {
        var data=checkDataAjax(res);
        if(data){
            step++;
            param_list[step] = data.list;
            selectable.html(data.list).fadeTo(0,1).scrollTo(0);
            if (step==2) {
                var item=$('#selectable > li');
                if(item.length==1){item.click()}
            }
        }else{}
    }
</script>

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148716
    • Total Posts
      644534
×
×
  • Create New...