0

我在弹出窗口中遇到了 datetimepicker 的问题。当我在简单的文本输入字段(使用 onfocus)上使用 datetimepicker 日历时,它工作正常,在这种情况下,我可以选择所有日期和时间,并且日历将保持可见,直到我选择日期和时间并单击完成。我还为这个砑光机添加了两个必要的 jquery,但是由于砑光机工作正常,所以我认为你不需要它们(如果需要的话,请说我。)工作案例的代码如下:

网页

<form name="deliveryform" id="deliveryform" action="<?php echo $_restaurant->getMerchantMenuUrl(); ?>" method="post" >
<div id="timenew" style="float:left; width:44%; display:block;margin-top:7px;"><input type="text" name="example12" id="example12" value="click here" onfocus="return showdatetimes();" size="18" />
</form>

脚本

function showdatetimes()
{

$('#example12').datetimepicker({
minDate: 0
});

$('#ui-datepicker-div').css({"z-index":'15'});

}

如你看到的 :在此处输入图像描述

然后压光机工作得很好。当我点击输入字段时打开,但在我点击完成之前保持可见。现在的问题是我想在弹出窗口中输入现在或以后的选项,在这种情况下,当我单击日历以选择日期或时间时,它会在单击时消失,所以我无法选择时间,或其他日期。我使用的代码是这样的:

html

<div id="fade" class="black_overlay"></div>
<div id="light" class="white_content">
<div>
<?php 
if ($language_settings == "francais")
{
?>
<form name="deliveryform" action="<?php echo $_restaurant->getMerchantMenuUrl(); ?>"     method="post" onSubmit="return ckeckvalueofform('francais');" >
<div style="margin-left:30px;"><b>SVP choisir votre service?</b></div>
<div style="margin-left:-10px;margin-top:20px;"><input type="radio" name="deliverytype"    id="pickup" value="Pick up">&nbsp;&nbsp;Ramassage au magasin &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="deliverytype" id="delivery" value="delivery">&nbsp;&nbsp;Livraison</div>
<div style="margin-left:90px;margin-top:15px;"><input type="submit" name="submitdlform"  id="submitdlform" value="Soumettre" class="view-all" style="background- color:#851811;color:#FFFFFF;width:80px;height:33px;" /></div>
</form>
<?php
}
else
 {
?>
<form name="deliveryform" action="<?php echo $_restaurant->getMerchantMenuUrl(); ?>"   method="post" onSubmit="return ckeckvalueofform('english');" >
<input id="currenttime" name="currenttime" value="<?php echo $currenttime ?>" type="hidden" />
<input id="operational_hr_fr" name="operational_hr_fr" value="<?php echo $operational_hr_fr ?>"   type="hidden" />
<input id="operational_hr_to" name="operational_hr_to" value="<?php echo $operational_hr_to ?>" type="hidden" />
<div style="margin-left:10px;"><b>Please select your delivery type?</b></div>
<div style="border-top:2px solid #CCCCCC;"> 
<div style="margin-left:47px;margin-top:10px;"><input type="radio" name="deliverytype" id="pickup" value="Pick up">&nbsp;&nbsp;Pick up &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="deliverytype" id="delivery" value="delivery">&nbsp;&nbsp;Delivery</div>
</div>
<div style="margin-left:10px;margin-top:10px;"><b>
<?php if ($language_settings == "francais")
{echo 'Quand voulez-vous votre commande?';}else{ echo 'when do you want your order?';}?></b>
</div>
<div style="border:1px solid #CCCCCC;">
<div style="float:left; width:51%; padding:10px 0 0 10px;">
<?php if ($language_settings == "francais")
{echo 'Maintenant';}else{ echo 'Now';}?>&nbsp;<input type="radio" name="ordtimesel" value="n"     id="ordtimeseln" checked="checked" onchange="showhidetimes(this.value);" />&nbsp;<?php if        ($language_settings == "francais")
{echo 'ou Tantot';}else{ echo 'or Later';}?>&nbsp;<input type="radio" name="ordtimesel" value="l"  id="ordtimesell" onchange="showhidetimes(this.value);" />    
</div>
<div id="timenew" style="float:left; width:44%; display:none;margin-top:7px;"><input type="text"  name="example12" id="example12" value="click here" onfocus="showdatetimes();" size="18" /></div>
</div>
<div style="margin-left:80px;margin-top:60px;"><input type="submit" name="submitdlform" id="submitdlform" value="Submit" class="view-all" style="background-color:#851811;color:#FFFFFF;width:80px;height:33px;" /></div>
</form>
<?php 
}
?>
<a href = "javascript:void(0)" onclick =  "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"><img src="<?php echo $this->getSkinUrl('images/deliveryclose.png'); ?>" style="margin-top:-171px;margin-left:257px;"></a>
</div> 
</div>

弹出样式

                       .black_overlay{
                        display: none;
                        position: absolute;
                        top: 0%;
                        left: 0%;
                        width: 100%;
                        height: 2500px;
                        background-color: black;
                        z-index:1001;
                        -moz-opacity: 0.8;
                        opacity:.80;
                        filter: alpha(opacity=80);
                    }
                    .white_content {
                        display: none;
                        position: fixed;
                        top: 20%;
                        left: 45%;
                        width: auto;
                        height: auto;
                        padding: 16px;
                        border: 2px solid #f19317;
                        background-color: white;
                        z-index:1002;
                        overflow: auto;
                        margin:0  0  0  -120px;

                    }

脚本

 function showdatetimes()
{

$('#example12').datetimepicker({
minDate: 0
});

$('#ui-datepicker-div').css({"z-index":'15'});

}


 function showhidetimes(val)
 {
 if(val == 'l') 
 {
 document.getElementById("timenew").style.display = 'block';    
$('#example12').datetimepicker({
minDate: 0
});

$('#ui-datepicker-div').css({"z-index":'15'});
$('#ui-datepicker-div').css({"top":'152.6px'});
$('#ui-datepicker-div').attr('id', 'white_content');

 }
if(val == 'n') 
{
document.getElementById("timenew").style.display = 'none';  
 }
}

我在magento中做这整件事,在第二种情况下,我的日历消失了,但是这个文件中有很多其他代码,我粘贴了我找到的相关内容,如果你找到了,那么你可以在这里检查整个代码(http://pastebin.com/JgcE9f1P ).. 祝你好运来解决我的问题,希望有人一定会查找我错过的内容:P 我想要这样的东西: 在此处输入图像描述

4

0 回答 0