Jump to content

JMRKER

Members
  • Posts

    194
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by JMRKER

  1. Regardless of native JS or JQuery, perhaps this would help with your understanding:

    	<script>
    var globalVar = 'globalVar';
    	function parentFunc() { // no function parameters
      var parentVar = 'parentVar';
    	  function childFunc() { // not function parameters
        var childVar = 'childVar';
        alert('childFunc has access to:\n'+childVar+'\n'+parentVar+'\n'+globalVar);
      }
    	  childFunc();
      alert('parentFunc has access to:\n'+parentVar+'\n'+globalVar);
    }
    alert('body has access to only:\n'+globalVar);
    parentFunc();
    </script>
    	

     

    • Like 1
    • Thanks 1
  2. One solution (of many) possible.

    	<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title> setTimeout Displays </title>
    <!-- From: http://w3schools.invisionzone.com/topic/58090-using-settimeout-in-a-for-loop/ -->
    	<style>
     .tips { display: none; }
    </style>
    	</head>
    <body>
    <button id="startGuide"> Start Guide </button>
    	<div id="tip0" class="tips"> Tip 1 </div>
    <div id="tip1" class="tips"> Tip 2 </div>
    <div id="tip2" class="tips"> Tip 3 </div>
    <div id="tip3" class="tips"> Tip 4 </div>
    <div id="tip4" class="tips"> Tip 5 </div>
    <div id="tip5" class="tips"> Tip 6 </div>
    <div id="tip6" class="tips"> Done </div>
    	<div id="debug"><br><!-- tipCnt, if used --></div>
    <script>
    	var startG = document.getElementById("startGuide");
    	var guidetips = [];
    guidetips[0] = document.getElementById("tip0");
    guidetips[1] = document.getElementById("tip1");
    guidetips[2] = document.getElementById("tip2");
    guidetips[3] = document.getElementById("tip3");
    guidetips[4] = document.getElementById("tip4");
    guidetips[5] = document.getElementById("tip5");
    guidetips[6] = document.getElementById("tip6");
    	var tip = '', tipCnt = 0, tipTime = 1000;
    	function toggleTip(){
      if (tipCnt < guidetips.length) {
        if (tipCnt > 0) { guidetips[tipCnt-1].style.display = 'none'; }
        clearTimeout(tip);
        tip = setTimeout('toggleTip()', tipTime);
        if (tipCnt < guidetips.length) {
          guidetips[tipCnt].style.display = 'block';
          tipCnt++;
        } else { guidetips[tipCnt].style.display = 'none'; }
      } else { clearTimeout(tip);  tipCnt = 0; }
    	//  document.getElementById('debug').innerHTML = tipCnt;  // optional display
    }
    	function init() {
      document.getElementById('startGuide').addEventListener('click', function() { toggleTip(); } );
    } init();
    </script>
    	</body>
    </html>
    	

     

  3. 8 hours ago, dsonesuk said:

    Local storage is not practical as it would not store anyone else's click count but your own, it would not sync with anyone's else's clicks or the current total of clicks.

    Sorry, but I did not see any requirement from OP that the code requested needed to be on a server,
    hence the initial question.  Obviously the OP has his/her answer or has given up. 
    Either way, no need to argue about requirements when either could work if there were more request clarification.

  4. On 7/18/2018 at 5:14 PM, dsonesuk said:

    The count is stored in a single row with a id ref, and probably a count identifier if you have more than one counter on a database, local storage stores data specific to the user visiting a site, it will never able to register and update other users triggering a count event.

    Every time someone clicks the button or whatever, it goes to the database and increments the current value by 1, the current total result is then retrieved and shown on the website.

    Sorry, I understood your suggestion.  I have used it in the past as well.

    What I was asking the OP for was clarification as to how the count request was to be used.  Server (your solution) or client side (via local storage).

  5. Unclear on the request, so for clarification:

    Does the button count need to be stored on the server for counts from more than one user?

    Or, can the button count be saved (and/or reset) with local storage on the users single computer?

  6. You can simplify it even further ...

    	 
    	<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title> HTML5 page </title>
    	<style>
     .columnList2 {
        -webkit-column-count: 2; /* Chrome, Safari, Opera */
        -moz-column-count: 2; /* Firefox */
        column-count: 2;
     }
     ul { list-style: none; }
    </style>
    	</head>
    <body>
    <ul class="columnList2">
     <li>Mr. Smith</li>
     <li>123 Main</li>
     <li>Somewhere, CA 12345</li>
    	 <li>Ms. Baker</li>
     <li>456 Central</li>
     <li>Other City, FL 32165</li>
    </ul>
    	</body>
    </html>
    	 
    	

  7. Not sure how your data is formatted, but using JSON format as an example.

    You could modify the following to suit your needs (???).

    	<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title> HTML5 page </title>
    <!--For: http://w3schools.invisionzone.com/topic/58061-html-columns/ -->
    	<style>
     #customersInfo { width: 30em; border: 1px solid red; }
     #customersInfo > input { width: 15em; border: 0; background-color: yellow; margin: 0.5em; }
    </style>
    	</head>
    <body>
    <p> Starting text </p>
    <fieldset id="customersInfo"> <legend for="customersInfo">Customers Information</legend>
     <input id="name0" value="">
     <input id="name1" value="">
     <br>
     <input id="addr0" value="">
     <input id="addr1" value="">
     <br>
     <input id="csz0" value="">
     <input id="csz1" value="">
    </fieldset>
    <p> More text </p>
    	<script>
    var customers = [
       {"name":"Mr. Smith", "addr":"123 Main",    "city":"Somewhere",  "st":"CA", "zip":"12345"},
       {"name":"Ms Baker",  "addr":"456 Central", "city":"Other City", "st":"FL", "zip":"32165"}
    ];
    	function doc(IDS) { return document.getElementById(IDS); }
    function init() {
      for (var i=0; i<customers.length; i++) {
        doc('name'+i).value = customers[i].name;
        doc('addr'+i).value = customers[i].addr;
        doc('csz'+i).value = customers[i].city+', '+customers[i].st+' '+customers[i].zip;
      }
    } init();
    </script>
    	</body>
    </html>
    	

     

  8. 3 hours ago, Sigmahokies said:

    Hey, hey! I just fixed what I want. 

    all i have to remove "+" from =. it count as one! Thank you so much!

    Well, I'm glad it solved your problems, but I don't know how it did.

    Can you give an example of the HTML layout with 3 groups of 3 checkbox and show how clicking on 2 and 1 and 2 in each of the groups (A,B,C) makes a total of 9 checked boxes?

    ... "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? "

    Nope, I don't get it.  I'm glad it worked for you, but I don't understand how.

  9. Sure, why not?

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title> HTML5 page </title>
    <!-- link rel="stylesheet" href="common.css" media="screen" -->
    <style>
     fieldset { width: 10em; }
    </style>
    </head>
    <body>
    
    <fieldset id="GC"> <legend>Group Count</legend>
     <input type="checkbox" value="4"> 2<sup>2</sup>
     <input type="checkbox" value="2"> 2<sup>1</sup>
     <input type="checkbox" value="1"> 2<sup>0</sup>
    </fieldset>
    <input type="button" value="Submit Group Count" id="submit">
    
    <script>
    function summate() {
      var sel = document.getElementById('GC').querySelectorAll('input'),
          sum = 0;
      for (var i=0; i<sel.length; i++) {
        if (sel[i].checked) { sum += Number(sel[i].value); }
      } // return sum;
      alert('Sum: '+sum);
    }
    function init() {
      document.getElementById('submit').addEventListener('click',summate);
    } init();
    </script>
    </body>
    </html>
    
    

     

    • Thanks 1
  10. Don't know if there is a problem with your code as I don't see any questions.

    However, in your first four functions you define "blok" as a  local variable in 3 of them and a global in the other.

    	       function verwijderLijn(demo) {
               blok = document.getElementById(demo);
               lijnen = blok.getElementsByTagName("hr");
               if (lijnen.length > 0) {
                   blok.removeChild(lijnen[lijnen.length - 1]);
               }
           }
    	

    Was that intentional?

     

  11. On 4/5/2018 at 8:24 AM, MGLP said:

    My HTML is:

    [While($cntr < $NumRcds)
    {$cntr=$cntr+1;
    print("[<input type=\"radio\" name=\"choice\" id=\"rcd\" value=\"$Row[6]\"><br>");}]

    which gives me many records listed with each having a radio button.

    Upon Submit, I want to test if at least 1 button has been checked.

    My Java is the following and I've tried various other versions non of which work.

    Can you tell me what the code should be.

    [function formcheck()
    {if(name.choice.checked==true){return true;}
    else{alert(\"At least one record must be selected in order to DELETE.\");return false;}}]

    Thank you

     

    What language are you trying to write with?  Java or Javascript?

    There is not a native "print" function in Javascript.  If the code is Java, then you would get better answers in that forum.

     

  12. As 'dsonesuk' says, have you tried this ...

    	<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title> HTML5 page </title>
    	<style>
     .hide { display: none; }
    </style>
    	</head>
    <body>
     <button onclick="myFunction('myDIV')">Click Me</button>
    	 <div id="myDIV" class="hide">
      This is my DIV element.
     </div>
    	<script>
    function myFunction(info) { document.getElementById(info).classList.toggle('hide'); }
    	</script>
    	</body>
    </html>
    
    

     

  13. Have you tried this?

    	<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title> HTML5 page </title>
    </head>
    <body>
    <div class="form-group">
      <label class="col-sm-4 control-label">Checkbox inputs</label>
      <div class="col-sm-8">
        <div class="checkbox check-transparent">
          <label for="opt01">Option 1</label>
          <input type="checkbox" value="1" id="opt01" checked>
        </div>
        <div class="checkbox check-transparent">
          <label for="opt02">Option 2</label>
          <input type="checkbox" value="1" id="opt02">
        </div>
        <div class="checkbox check-transparent">
          <label for="opt03">Option 3</label>
          <input type="checkbox" value="1" id="opt03">
        </div>
      </div>
    <div>
    </body>
    </html>
    	

    • Like 1
×
×
  • Create New...