【问题标题】:Background is not begin Disabled背景未开始已禁用
【发布时间】:2014-03-11 10:15:00
【问题描述】:

我正在开发一个网站。

搜索完成后,我将结果填充到弹出窗口中,但看到弹出窗口时背景并未禁用。

下面是 PHP 代码:

<div id="search">
    <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
        Search Muggu<br/>
        <span style="font-size:13px">(Ex:Muggu 21)</span><br/>
        <input type="text" name="number" class="searchtext" title="Enter Muggu with Number"/><br/>
        <input type="submit" Value="Get Muggu" name="SearchMuggu" class="searchmuggu"/><br/>
    </form>     
    <?php
        if(isset($_POST['SearchMuggu']))
        {   
            $search=$_POST['number'];
            $regex='/^Muggu[0-9]+$/';
            $regex1='/^muggu[0-9]+$/';
            $regex2='/^muggu [0-9]+$/';
            $regex3='/^Muggu [0-9]+$/';
            if((preg_match($regex,$search))||(preg_match($regex1,$search))||(preg_match($regex2,$search))||(preg_match($regex3,$search)))
            {
                $positionafteru=strrpos($search,"u")+1;
                $total=strlen($search);
                $diff=$total-$positionafteru;
                $number=substr($search,$positionafteru,$diff);

                include("DB.php"); //Connects to Database

                $sql=mysql_query("select ID,Path from storeimages where Number='$number' and type='.'") or die(mysql_error()); //Running the select query using where number is $_POST[SearchMuggu]

                if(mysql_num_rows($sql)>0)
                {
                    while($row=mysql_fetch_array($sql))
                    {
                        $path=$row['Path'];
                        $id=$row['ID'];
                        $id++;
                        echo "<div id='searchpopup'>
                                <a href='javascript:closesearch()' id='closepopup'>X</a><br/>
                                <span>Muggu ".$number."</span>
                                <a href='lrgimgview.php?id=".$id."' title='Click On Image for Step by Step'><img src='".$path."'/></a>
                             </div>
                             <div id='backgroundPopup'>
                             </div>";
                    }
                }
                else
                {
                    echo "<script type='text/javascript'>alert('".$search." Not Found');</script>";
                }
            }
            else
            {
                echo "<script type='text/javascript'>alert('please Enter in the following format Muggu1 or muggu1 or Muggu 1 or muggu 1');</script>";
            }
        }
    ?>
</div>

下面是脚本:

function closesearch(event)
{
    document.getElementById('searchpopup').style.display="none";
    document.getElementById('backgroundPopup').style.display="none";
}
var MyDiv1 = document.getElementById('searchpopup');
var MyDiv2 = document.getElementById('backgroundPopup').style.display='block';
MyDiv2.innerHTML = MyDiv1.innerHTML+MyDiv2.innerHTML;

这是下面的 CSS:

#searchpopup
{
    margin: 0 auto;
    width: 250px;
    height: 250px;
    background-color: white;
    border: 2px solid maroon;
    border-radius: 10px;
    top: 10%;
    left: 10%;
    position: relative;
    font-size: 15px;
    z-index:2;
}

#backgroundPopup 
{ 
    z-index:1;
    position: fixed;
    display:none;
    height:100%;
    width:100%;
    background-color:#D3BEE9;   
    top:0px;  
    left:0px;
    opacity: 0.2;
}

PHP 代码写在 header.php 中,并使用 PHP 的 include 语句包含在 index.php 中。 header.php 有其他编码,如网站的标志和会员代码。

你能帮帮我吗?

【问题讨论】:

    标签: javascript php css background popup


    【解决方案1】:

    我真的看不出哪里有问题,我有一个带有类似 HTML 的 jsFiddle here

    <div id="search">
    <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
        Search Muggu<br/>
        <span style="font-size:13px">(Ex:Muggu 21)</span><br/>
        <input type="text" name="number" class="searchtext" title="Enter Muggu with Number"/><br/>
        <input type="submit" Value="Get Muggu" name="SearchMuggu" class="searchmuggu"/><br/>
    </form>
    <div id='searchpopup'>
                                <a href='javascript:closesearch()' id='closepopup'>X</a><br/>
                                <span>Muggu</span>
                                <a href='lrgimgview.php?id=lala' title='Click On Image for Step by Step'><img src='lala'/></a>
                             </div>
                             <div id='backgroundPopup'>
                             </div>
    </div>
    

    好像没问题... 我建议您直接在您的 HTML 代码中设置您的 baground div,而不是在您的 PHP 代码中。然后在搜索完成时显示它。 对不起,我只有那个解决方案 =(

    【讨论】:

      猜你喜欢
      • 2011-04-26
      • 2022-11-18
      • 2013-05-21
      • 1970-01-01
      • 2017-12-02
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多