背景未开始禁用

时间:2014-03-11 10:15:01

标签: javascript php css background popup

我正在开发一个网站。

搜索完成后,我会在弹出窗口中填充结果,但是当看到弹出窗口时,后台不会被禁用。

以下是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还有其他编码,如网站的标识,并且是会员代码。

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

我真的没有看到它出错的地方,我有一个jsFiddle here,其中包含这样的HTML:

<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代码中。然后在搜索完成时显示它。 对不起,我只有那个解决方案=(