Jump to content

davej

Moderator
  • Posts

    3,988
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by davej

  1. On 6/23/2018 at 2:23 PM, Sigmahokies said:

    That is not what I am asking for. I am asking for to have few checkbox have been checked, but count as one. For example, If I put nine checkboxes on website, then I divide nine checkboxes into three group: Three checkboxes in one group, then three checkboxes in second group, then three checkboxes in third group, suppose someone click checkboxes two out of three checkboxes in first group, click one out of three checkboxes in second one, then click two out of three checkboxes in third one, so script would count three checked because it showed someone did it all nine checkboxes which divided into three group that will count as three checked. Get it?

     

    You want a Php variable to count up the checkboxes in this manner, but don't you also want to know which exact checkboxes were checked?

  2. Well, I am aware of this, but I keep seeing claims that the "blockchain" itself is an important idea. For example it is claimed that IBM is working on 400+ different blockchain-based concepts. I think they are proposing that it can be useful for a variety of secure distributed/decentralized transactional systems.

  3. <?php
    session_start();
    $pageLevel = "4";
    $user = isset($_SESSION['user']) ? $_SESSION['user'] : '';
    $userLevel = isset($_SESSION['userlevel']) ? $_SESSION['userlevel'] : '';
    ?>
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>title</title>
    </head>
    <body>
    
    <?php
    if ($user == '' || $userLevel == ''){ 
    ?>
    
    <h1>Forbidden. You do not have permission to view this page.</h1>
    
    <?php
    }else if($pageLevel > $userLevel){
    ?>
    
    <h1>Sorry <?php echo $user ?>. You do not have permission to view this page.</h1>
    
    <?php
    }else{
    ?>
    
    <div id="content">
    
    <h1>Welcome <?php echo $user ?></h1>
    <h4>This is the protected content.</h4>
    
    </div>
    
    <?php
    }
    ?>
    
    </body>
    </html>

     

  4. I am leaning toward positioning the images under the canvas and positioning matching divs over the canvas. That way the images are protected and the mouseover events can be assigned to the divs.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset='utf-8'>
    <title>MouseOver Event on Canvas</title>
    <style>
    #container{
    z-index: 0;
    position: relative;
    height:700px;
    width:700px;
    background-color: pink;
    }
    #myCanvas { 
    z-index: 10;
    border: #333 10px solid; 
    position: absolute;
    top: 50px;
    left: 40px;
    height: 600px;
    width: 600px;
    }
    #squ1 { 
    /* opacity:0; */
    border: 1px solid red; 
    z-index: 20;
    position: absolute;
    top: 100px;
    left: 100px;
    height: 100px;
    width: 100px;
    }
    #squ2 { 
    /* opacity:0; */
    border: 1px solid blue; 
    z-index: 20;
    position: absolute;
    top: 500px;
    left: 500px;
    height: 100px;
    width: 100px;
    }
    #pic1{ 
    z-index: 1;
    position: absolute;
    top: 100px;
    left: 100px;
    height: 100px;
    width: 100px;
    }
    #pic2{
    z-index: 1;
    position: absolute;
    top: 500px;
    left: 500px;
    height: 100px;
    width: 100px;
    }
    
    </style>
    </head>
    
    <body>
    
    <div id="container">
    <div id="squ1"></div>
    <div id="squ2"></div>
    <canvas id="myCanvas"></canvas>
    <image id="pic1" alt="1"/>
    <image id="pic2" alt="2"/>
    </div>
    
    <script>
    document.getElementById('squ1').addEventListener('mouseover',squ1over,false);
    document.getElementById('squ2').addEventListener('mouseover',squ2over,false);
    
    var src1 = "https://uploads.guim.co.uk/2017/10/06/First-Dog-on-the-Moon,_L.png";
    var src2 = "https://image.freepik.com/free-vector/cheese-cartoon_22350-100.jpg";
    
    var img1 = document.getElementById('pic1');
    var img2 = document.getElementById('pic2');
    img1.src = src1;
    img2.src = src2;
    
    var canvas = document.getElementById('myCanvas');
    
    
    function squ1over(){
      alert('squ1 touched');
    }
    
    function squ2over(){
      alert('squ2 touched');
    }
    
    </script>
    </body>
    </html>

     

  5. If you have a canvas and you want to have some number of visible images on it with mouseover events (or the equivalent) for each image what is the most efficient approach to accomplish this? Is it possible to use the images in some manner with mouseover events? Or must I simply use the mousemove event and keep checking the mouse coordinates? Thanks.

  6. You need to clarify what you are trying to do. You are not allowed to have two identical id values on the same page because that is illegal HTML. Also these id values seem to be unnecessary -- they don't serve any purpose. Also if these radio buttons all have the same name then ONLY one of them can be checked.

  7. 4 hours ago, iwato said:

    Davej:  Why would you make the private and not public?

    Instance variables are usually declared as private because OOP considers "encapsulation" to be a good thing. This is the same reasoning behind minimizing the number of global variables. If some variable does not need to be public or global then it shouldn't be. In your example the constructor sets the values of the instance variables, so they themselves don't need to be public.

    • Thanks 1
  8. Be aware that it is always to the benefit of the student to modify the code in the Tryit editor in order to verify your understanding of whatever is presented. In the code you mention it is difficult to guess whether the student would know that the following is equivalent...

    var myResult = myFunction(3,4); // call the function
    document.getElementById("demo").innerHTML = myResult; // display the result

     

  9. Screen capture images are inappropriate for posting code. Use the code block <> provided in the online editor and paste in your code. SynWrite is merely an editor and has no relevance to your question. I have no idea what a "restore down" button is supposed to do. If your web page is live online then simply supply the link.

×
×
  • Create New...