Jump to content

Show & Hide


AnotherQuestion

Recommended Posts

Actually re-read the post a few times makes more sense now, though can't see why you'd think you'd use PHP for this? It's a JavaScript problem (and nothing to do with AJAX, priti). There's probably a variety of ways you could do this, here's a very rough demo of how it could be done:

 

<html>
<head>

<script type="text/javascript">
function updateChecks() {
    var check = document.forms[0].elements['checkbox_name'];
    var check_count = 0;

    for (i = 0; i < check.length; i++) {
        if (check[i].checked == true) {
            check_count++;
        }
    }

    if (check_count >= 5) {
        document.getElementById('your_image').style.display = 'block'; // or 'inline' depending on element / desired position
    } else {
        document.getElementById('your_image').style.display = 'none';
    }

    return true;
}
</script>

</head>
<body>

<form>
    <input type="checkbox" name="checkbox_name" value="check1" onclick="updateChecks();" /> check1<br />
    <input type="checkbox" name="checkbox_name" value="check2" onclick="updateChecks();" /> check2<br />
    <input type="checkbox" name="checkbox_name" value="check3" onclick="updateChecks();" /> check3<br />
    <input type="checkbox" name="checkbox_name" value="check4" onclick="updateChecks();" /> check4<br />
    <input type="checkbox" name="checkbox_name" value="check5" onclick="updateChecks();" /> check5<br />
</form>

<img src="img/my_image.jpg" alt="your Image" id="your_image" style="display: none;" />

</body>
</html>

 

Obviously you'll need to adapt this more to your needs but, should be a good starting point.

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.