dtpd58676 2013-09-24 13:16
浏览 24

首先单击选择不选择值

Hello i got problem with my select box in HTML. First click on this box sometimes doesn't selecting the value but only "focusing" it? (i don't know that this is a good word for it) I made screen to help You explain what i mean:

Link to image

What can i do to avoid this? When user will click i have to show the right place on the map

Some parts of my code:

echo '<select id="selector'.$i.'" style=" height: 100%; width: 228px; margin: 2px;" onchange="JumpToPoint(this.value);">';
while($street = mysql_fetch_array($streets, MYSQL_ASSOC))
{
   echo '<option value="'.$street['x'].','.$street['y'].'">'.$street['name'].'</option>';        
}
echo '</select></div>';

It is any possibility to simulate this focus ? Because only first click is focusing value - the socond, third etc always selecting the right value

I found that the problem is with this function:

    jQuery.fn.filterByText = function(textbox) {
    return this.each(function() {
        var select = this;
        var options = [];
        $(select).find('option').each(function() {
            options.push({value: $(this).val(), text: $(this).text()});
        });
        $(select).data('options', options);

        $(textbox).bind('change keyup', function() {
            var options = $(select).empty().data('options');
            var search = $.trim($(this).val());
            var regex = new RegExp(search,"gi");

            $.each(options, function(i) {
                var option = options[i];
                if(option.text.match(regex) !== null) {
                    $(select).append(
                        $('<option>').text(option.text).val(option.value)
                    );
                }
            });
        });
    });
};

But i don't know where

Thanks in advance for help.

  • 写回答

2条回答 默认 最新

  • dosrmo0442 2013-09-24 13:31
    关注

    I don't see why you don't just use the 'change' event for your jQuery event instead of the 'click' event so going with the code you put up and assuming you are using jQuery try this :

    <script type="text/javascript">
    $(document).ready(function() {
       $('#selector<?php echo $i ?>').change(function() {
          /** change map code goes here **/
       });
    });
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗