javascript - 日期选择器定位无法正常工作

标签 javascript php jquery html datepicker

我有一个搜索框,用于搜索某个时期内的一系列日期,用户可以使用 jquery 中的日期选择器插件进行选择。我遇到的问题是,启用日期选择器的位置出现在页面的左下角,而不是直接在搜索框下方。我已经提供了用于 jquery 和 HTML 部分的标记。谁能告诉我如何纠正这个问题?

jQuery:

<script type="text/javascript" src="includes/javascript/daterangepicker.jQuery.js"></script>

<script type="text/javascript"> 
    $(function(){
        if($(window.parent.document).find('iframe').size()){
            var inframe = true;
        }

        $('.datepick').daterangepicker({
            arrows: false, 
            dateFormat: 'dd/mm/yy',
            posX: null,
            posY: null,
            onOpen:function(){ 
                if(inframe){
                    $(window.parent.document).find('iframe:eq(0)').width(700).height('35em');
                } 
            }, 
            onClose: function(){ 
                if(inframe){
                    $(window.parent.document).find('iframe:eq(0)').width('100%').height('5em');
                } 
            }
        }); 

    });
</script>

HTML:

<table border="0" align="right">
    <tr>
        <?php echo tep_draw_form('search_date_purchased', FILENAME_ORDERS, '', 'post'); ?>

        <td class="smallText" align="right">
            <?php echo TEXT_ORDER_DATE;?>
            &nbsp;
            <input type="text" name="search_date_purchased" placeholder="Choose a Date" class="datepick" value="<?php echo $HTTP_POST_VARS['search_date_purchased'];?>">
            &nbsp;
            <input src="./images/Search.png" alt="Search" title="Search" border="0" type="image">
        </td>
    </form>
    </tr>
</table>

最佳答案

您的 html 无效: 你的 html 中有一个结束表单标签。另外,您还尝试回显 tr 标记内的某些内容,该内容不是有效的 html。您需要在 td 标记内进行回显。

<table border="0" align="right">
     <tr>
       <td><?php echo tep_draw_form('search_date_purchased', FILENAME_ORDERS, '', 'post'); ?></td>
       <td class="smallText" align="right"><?php echo TEXT_ORDER_DATE;?>&nbsp;<input type="text" name="search_date_purchased" placeholder="Choose a Date" class="datepick" value="<?php echo $HTTP_POST_VARS['search_date_purchased'];?>">&nbsp;<input src="./images/Search.png" alt="Search" title="Search" border="0" type="image"></td>     
     </tr>
</table>

关于javascript - 日期选择器定位无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18979646/

相关文章:

jquery - jquery ajax成功中的location.href未触发

href onclick请求中的Javascript传递变量

javascript - 阶乘/组合在不应该的情况下产生 NaN

javascript - async/await Promise.all() 但在 promise 解析时得到响应

javascript - 如何从 javascript 文件中的 web.config 读取键值?

php - 浮点精度问题仅影响计算吗?

php - mysqli_stmt::bind_param():类型定义字符串中的元素数量与绑定(bind)变量的数量不匹配

php - 如果我们从 php 脚本发送邮件到 gmail 或其他邮件应用程序,是否有任何过滤器,例如垃圾邮件和任何其他程序

jquery - 在 HTML 中使用内容框

javascript - 悬停时将颜色层放在背景图像上的 Css 动画