简体   繁体   中英

Hide div with all content in this

i want to hide div with all content in div this is my code :

<form action="" method="POST" name="form">
<p for="name">text :</p><input type="text" name="name" value="<?php echo $name_g; ?>" onfocus="ClearPlaceHolder (this)" onblur="SetPlaceHolder (this)"/>
<p for="phone">text :</p><input type="text" name="phone" value="<?php echo $phone_g; ?>" onfocus="ClearPlaceHolder (this)" onblur="SetPlaceHolder (this)"/>
<p for="blood">text :</p><input type="text" name="blood" value="<?php echo $blood_g; ?>" onfocus="ClearPlaceHolder (this)" onblur="SetPlaceHolder (this)"/>
<p for="id">text :</p><input type="text" name="id" value="<?php echo $id2_g; ?>" onfocus="ClearPlaceHolder (this)" onblur="SetPlaceHolder (this)"/>
<p for="email">text : </p><input type="text" name="email" value="<?php echo $email_g; ?>" onfocus="ClearPlaceHolder (this)" onblur="SetPlaceHolder (this)"/>
<input type="button" onclick =" printvalues();" value="text"> 

<div id="info_check">
<script type="text/javascript">
    function printvalues() {
        var div = document.getElementById("info_check");
        div.innerHTML += "<span>text :</span>"+form.name.value+"<br>";
        div.innerHTML += "<span>text :</span>"+form.phone.value+"<br>";
        div.innerHTML += "<span>text :</span>"+form.blood.value+"<br>";
        div.innerHTML += "<span>text :</span>"+form.id.value+"<br>";
        div.innerHTML += "<span>text :</span>"+form.email.value+"<br>";
        div.innerHTML += "<input type='submit' name='sub' value='text'/>";
        $("#info_check").show();
    }
</script>
<h2>text</h2>
<input type='button' onclick="$('#info_check').hide();" value='text' style='background: #F00 none repeat scroll 0% 0%; min-width: 20px; width: 80px;color: #fff; border-radius:4px; text-decoration: none; margin-right: 10px;'/>
</div>
</form>

my problem is i want to hode #info_check with all content in this

As per my understnding, you want to show the preview of the form user has filled.

Try this:

<!DOCTYPE html>
<html>
<body>
    <form action="">
        <div id="info_check"></div>
    </form>
    <input type='button' onclick="$('#info_check').hide();" value='Hide The Div'/>
    <input type='button' onclick="$('#info_check').show();" value='Show The Div'/>
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript">
        function printvalues()
        {
            var div=document.getElementById("info_check");
            div.innerHTML+="<span>text :</span>some values<br>";
            div.innerHTML+="<span>text :</span>some values<br>";
            div.innerHTML+="<span>text :</span>some values<br>";
            div.innerHTML+="<span>text :</span>some values<br>";
            div.innerHTML+="<span>text :</span>some values<br>";
            div.innerHTML+="<input type='submit' name='sub' value='Submit'/>";
        }
        printvalues();
    </script>
</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM