Jump to content

Search the Community

Showing results for tags 'javascript'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 830 results

  1. I like the automatic slideshow in the example here: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_slideshow_auto, but would like 2 slideshows on one page. When I try to do this myself, one slideshow plays and finishes, then the other one starts and finishes. I would like them to start at the same time and loop and like the caption option but don't necessarily need the "dots".
  2. Hi, i love the w3school web, I learn for first time coding here and so im fun because I have job with coding relation. But for React so hard to learn with bad english spech knowledge. So the w3school can added new tutorial about React JS? Thanks..
  3. Hello, I am using the How to Create Tabs tutorial (https://www.w3schools.com/howto/howto_js_tabs.asp), but I can't get the default tab to work. It seems to work in the Tryit Editor, but even pasting the code as is, it doesn't work. I am using Shopify and have a .js, .css, and a .liquid (page template) document. Other changes on the pages seem to take affect. {{ 'tabs.js' | asset_url | script_tag }} {{ 'tabs.css' | asset_url | stylesheet_tag }} {% include 'breadcrumb' %} <meta name="viewport" content="width=device-width, initial-scale=1"> <div class="grid"> <div class="grid-item large--two-thirds push--large--one-sixth"> <h1>{{ page.title }}</h1> <div class="rte"> <h2>Tabs</h2> <p>Click on the x button in the top right corner to close the current tab:</p> <div class="tab"> <button class="tablinks" onclick="openCity(event, 'London')" id="defaultOpen">London</button> <button class="tablinks" onclick="openCity(event, 'Paris')">Paris</button> <button class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</button> </div> <div id="London" class="tabcontent"> <span onclick="this.parentElement.style.display='none'" class="topright">&times</span> <h3>London</h3> <p>London is the capital city of England.</p> </div> <div id="Paris" class="tabcontent"> <span onclick="this.parentElement.style.display='none'" class="topright">&times</span> <h3>Paris</h3> <p>Paris is the capital of France.</p> </div> <div id="Tokyo" class="tabcontent"> <span onclick="this.parentElement.style.display='none'" class="topright">&times</span> <h3>Tokyo</h3> <p>Tokyo is the capital of Japan.</p> </div> {{ page.content }} </div> </div> </div> function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; } // Get the element with id="defaultOpen" and click on it document.getElementById("defaultOpen").click(); /* Change background color of buttons on hover */ .tab button:hover { background-color: #ddd; } /* Create an active/current tablink class */ .tab button.active { background-color: #ccc; } /* Style the tab content */ .tabcontent { display: none; padding: 6px 12px; border: 1px solid #ccc; border-top: none; } /* Style the close button */ .topright { float: right; cursor: pointer; font-size: 28px; } .topright:hover {color: red;}
  4. I'm trying to create a form that allows for calculation of metabolic rate. There is an if,then statement related to gender (formula changes if female vs male) I'd also like the result to be targeted to a specific part of the page (anchor). Ideally a new section can appear (maybe need to link a new page?) to provide further details Below is my code, any help would be so appreciated!! <head> <style> body { font: 15px gothic, sans-serif; letter-spacing: 1px; } input { width: 100%; } input[type=number] { border: none; border-bottom: 1px solid grey; } input[type=button], input[type=submit], input[type=reset] { background-color: #ddcecb; border: none; -moz-border-radius: 5px; -webkit-border-radius: 5px; color: #95483e; padding: 16px 32px; text-decoration: none; letter-spacing: 1px; margin: 4px 2px; #submit:hover { border: none; background: #d2d1d1; box-shadow: 0px 0px 1px #777; }} input[type=text]:focus { border: 1px solid #555; } .form-inline label { margin: 5px 10px 5px 0; } @media (max-width: 800px) { .form-inline input { margin: 10px 0; } .form-inline { flex-direction: column; align-items: stretch; } </style> </head> <form name="RMRcalc"> weight (kg) : <input type="number" name="weight" autofocus><br><br> height (cm): <input type="number" name="height"> <br><br> age (years): <input type="number" name="age"> <br><br> activity Level: <select name="activity" margin=5px > <option value="1.2">sedentary (1-2x/week)</option> <option value="1.3">low (2-3x/week)</option> <option value="1.4">moderate (3-4x/week)</option> <option value="1.6">high (5+x/week)</option> </select> <br><br> female <input type="radio" name="gender" value="female" checked> <br> male <input type="radio" name="gender" value="male"> <br> <input type="submit" value="Calculate" id="calculate" onclick="RMRCalc ()" target="results"> <br><br> <script type="text/javascript"> "use strict" function RMRCalc () { var weight = document.getElementById ("weight").value; var height = document.getElementById("height").value; var age = document.getElementById("age").value; var activity = document.getElementById("activity").value; if (gender="female") var RMR = (10*weight) + (6.25*height) - (5*age) -161; document.getElementById("RMR").innerHTML=RMR; else var RMR = (10*weight) + (6.25*height) - (5*age) +5; document.getElementById("RMR").innerHTML=RMR; } </script> </form> <p><a name="results"> Your Daily Caloric Requirements: <div id ="RMR"></div> </a></p> <br> <p> Did you know that Thank you!!
  5. Hello. Any one here as experience with ionic 4 and express? I'm trying to do something simple: A simple login form for the user to enter login and password and a connect button. Once the user click on connect to send the data to the server. I wanna see the data on the server side maybe using an alert. Can anyone help me with that? It's been a couple of days I'm trying it. Please notice that I'm not trying something complex and the goal is to understand the concept, therefore the use of error handling, or whatever other utility to make the connection strong isn't necessary at all. Thanks ahead of time.
  6. BACKGROUND: Recently I discovered a nifty Javascript function that counts the like values of an index array and returns as its value an object whose property-value pairs consist of a single repeated value and its corresponding frequency. Unfortunately, I am having trouble understanding how the function works. As I have adapted it to fit my own needs I have changed the variable names. Indeed, this change may be the source of my own confusion. The FUNCTION: function dateCounter(dates) { return dates.reduce( (countDates, date) => { countDates[date] = ++countDates[date] || 1; return countDates; }, {} ); } REQUEST: Please write in plain English what the so-called reducer function of the reduce( ) function is achieving with each iteration. I am baffled. Roddy
  7. I am needing to convert an String input into an Integer. But before converting the String input, i have to do a validation that the String input can be converted to a numeric value. So If it cannot, i need to log a message saying “This cannot”. Then log another new log statement on the next line saying “be a number”. I understand I need a parseInt and isNan and if else statements but I am confused on exactly how they are implemented. I am new to javascript.
  8. I am designing a Sharepoint page with script editor. I have an image which I have used area tag on. So with onmouseover another image pops up and it reverts back onmouseout. I further want to use another area tag on this new image onmouseover where I can add area tags on this new image. Something like a nested image map. For description sake. I will use script from w3schools. <img src="planets.gif" width="145" height="126" alt="Planets" name="myname" usemap="#planetmap"> <map name="planetmap"> <area shape="rect" coords="0,0,82,126" onmouseover=myname.src="C:\Users\Quabynar\Pictures\sun.gif" ; onmouseout=myname.src="C:\Users\Quabynar\Pictures\planets.gif"> <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury"> <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus"> </map> I expect to put another map with area tags on the sun.gif when onmouseover where I can use href to say a link about description the Sun. I don't seem to get around it.
  9. Hey guys, I know that this is quite a longshot but I hope that there is someone here that can help me. We've had problems with our Store Locator on our homepage for quite a long time since it was missing an API Code (which we got today). The site I'm talking about is this: http://www.melon-helmets.com/en/stores The Problem is: I don't know where to put the API. There is this line of code <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> My guess was that I'd have to enter the API key after js?, by adding key=ourkey. It does display the map without an error afterwards, unfortunately it always asks me to enter a zip code or adress, even though I did so. (Tried City/Adress/ZIP Code) Can anyone help me? (I'm fairly poor at html/css/js) Thank you!
  10. HI, I'm using RPC.Query to send a string from js to py. At py receptor this scrash using json.loads(..) de args. The messages error is: "" ... JSONDecoderError(\"Expecting value\", s, err.value) from None\njson.decoder.JSONDecodeEror: Expecting value: line 1 colum1 (char 0)\n", "message": "Expecting value: line 1, column 1 (char 0)"], "Exception_type":"internal_error"}}" "" I do an console.log(..) beford RPC instruction and the string value is ok. That is the code: FROM JS: .... // *JCM* var strcontenido = ''; var LF = '\n'; var orderi = JSON.parse(JSON.stringify(order)); var orderf = JSON.parse(JSON.stringify(order_flushed)); strcontenido ="80#DOCUMENTO DE PRUEBA +LF80_is*YO MISMO+LF80_ir*22157456+LF80_i03Dirección: Calle, 12345678 Ciudad, Venezuela+LF80_i04Teléfono: +584161236548+LF80_i05Referencia: 00001-317-0204+LF80_i06Mesa: M5, Comensales: 1+LF80_@*****Gracias por su compra*****+LF80_#000000010000001000Golosinas+LF101" strcontenido= strcontenido.split(":").join("?"); // Replace ":" with "?" to send to py strcontenido= strcontenido.split(",").join("-"); // Replace "," with "-" to send to py console.log(strcontenido); // This show ok errTxt = self._crear_factura( true, strcontenido); var transfer = self._flush_orders([order_flushed], {timeout:30000, to_invoice:true}); // *JCM* // ...do some... }); return done; }); return invoiced; }, // Envia comandos al programa en python- Send command to py _crear_factura: function(imprime, strcontenido) { var self = this; var ejecuted = true; strcontenido = '{"F": "\'' +strcontenido + '\'"}' // Converting string to json inserting {"id": '...string...'} format var args = JSON.parse(strcontenido); console.log('ARGS=>>'+args); // This show text ok >> 80#DOCUMENTO DE PRUEBA +LF80_is*YO MISMO+LF80_ir*22157456+LF80_i03Dirección? Calle- 12345678 Ciudad- Venezuela+LF80_i04Teléfono? +584161236548+LF80_i05Referencia? 00001-317-0204+LF80_i06Mesa? M5- Comensales? 1+LF80_@*****Gracias por su compra*****+LF80_#000000010000001000Propinas+LF101 if (imprime) { return rpc.query({ model: 'pos.order', method: 'print_ticket', args: args, }).fail(function(error, event){ ejecuted = false; }); console.log('_crear_factura (\n' + strcontenido +'\n): Ejecutada...!!!'); } else { console.log('_crear_factura (\n' + strcontenido +'\n): NO EJECUTADA...!!!'); } return ejecuted; }, ... FROM py: @api.model def print_ticket(self, strcontenido): #contenido = strcontenido.get('F') // Error: strcontenido d'nt have get method contenido = json.loads(strcontenido) // Error: previus commented f=open('c:/IntTFHKA/invoiced1.txt','w') #if strcontenido.get('F'): // Error: strcont.... # contenido = strcontenido['strcontenido'] errVal=f.write(contenido["F"]) // Never cross at this... #else: # errVal=f.write('***** GENERAR LA FACTURA*****\n\n') #for data in strcontenido: errVal=f.write(data) errVal=f.write('\n\n*****FIN DEL ARCHIVO******\\nn') errVal = f.close() return True So, I had proved some method without result.... ¿Do you have any idea to resolv...??
  11. Is there anyway to make this dropdown menu use onclick instead of hover on small screens. I'm creating a menubar with several dropdowns and a couple sub-dropdowns with-in them and as it is on small screes the menu is too hard to navigate with the hover. https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_responsive_navbar_dropdown Thanks!
  12. Hi every one, My name is Antoine and I am trying to get all the pictures from a Facebook Page and Instagram Page. I've tried to make a jquery request like $('exemple').load('https://www.facebook.com/pg/stuffedfoxes/photos/ #id'); But it's not working because i don't have any direct id (embedded on the img container). My goal is to get all the 'http' directory of the images and to put them on my web page with my own css code. /* I don't want to use any API*/ Is it possible to load the entire page and filter all the information i need and erased all the others ? /* I'm open to all the solutions excepted if they are using API*/ THANKS PS( sorry for my miss takes im FR ; )
  13. I have used the script for creating an accordion from w3Schools . I would like to add a button somwhere on the page that would collapse all that are open. Even if it is just a reload of the page which would work. <script> var acc = document.getElementsByClassName("accordion"); var i; for (i = 0; i < acc.length; i++) { acc[i].addEventListener("click", function() { this.classList.toggle("active"); var panel = this.nextElementSibling; if (panel.style.display === "block") { panel.style.display = "none"; } else { panel.style.display = "block"; } }); } </script> Please help. I am definitely a newbie. Linda
  14. Hello, With reference to your "Responsive TopNav" example here: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_topnav it works fine for the most part, except that when the "hamburger" icon is used it does not close down again after making a selection. I have included my own slightly modified version of your example, simplified so there are only "home" and "news" menu items, and the hamburger icon will appear when reducing the width below 1000px. How can this be modified to collapse the hamburger links upon making a selection? Thanks... Jon <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <style> body { margin: 0; font-family: Arial, Helvetica, sans-serif; } .topnav { overflow: hidden; background-color: #333; position: absolute; left: 0; top: 0; width: 100%; } .topnav a { float: left; display: block; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; } .topnav a:hover { background-color: #ddd; color: black; } .active { background-color: #4CAF50; color: white; } .topnav .icon { display: none; } @media screen and (max-width: 1000px) { .topnav a:not(:first-child) {display: none;} .topnav a.icon { float: right; display: block; } } @media screen and (max-width: 1000px) { .topnav.responsive {position: relative;} .topnav.responsive .icon { position: absolute; right: 0; top: 0; } .topnav.responsive a { float: none; display: block; text-align: left; } } </style> </head> <body> <div class="topnav" id="myTopnav"> <a href="#home" class="active">Home</a> <a href="#news">News</a> <a href="javascript:void(0);" class="icon" onclick="myFunction()"> <i class="fa fa-bars"></i> </a> </div> <script> function myFunction() { var x = document.getElementById("myTopnav"); if (x.className === "topnav") { x.className += " responsive"; } else { x.className = "topnav"; } } </script> <div style="padding-left:16px; padding-top:40px"> <h2>Responsive Topnav Example</h2> <p>Resize the browser window to see how it works.</p> </div> <h2 id="home">Home</h2> asdf<br> asdf<br> asdf<br> asdf<br> asdf<br> asdf<br> <h2 id="news">News</h2> asdf<br> asdf<br> asdf<br> </body> </html>
  15. Hello everyone, I'm trying to create a RSA encryption, but seem it is not function correctly. Is Javascript know RSA? like, let rsa = new RSA(); do I have to download from github? here my code: let rsa = new RSA(); let prime = ["2", "3", "5", "7", "11", "13"] //<-- Prime number let random = prime[Math.floor(Math.random() * prime.length)]; let text = document.getElementById("readed"); document.getElementById("en").innerHTML = rsa.encrypt(random, text); Seem console log show it is not function.
  16. Hi everyone, I want to make clear again. I am trying to get data from "name" by PHP in HTML, but problem is "name" is used up by Javascript, but I need "name" for PHP's $_POST to get data from input from html, but can I use this "name" by JavaScript and PHP in same time? I need to get data from that word to post in database, but I think I'm stuck now...Anyone can tell me what is alternative keyword to get data from "name" in HTML? If you don't understand what I said, I will display and show you Thanks, Gary
  17. Well, I'm trying to make it so that the slide ends on the last page and shows a sign that whoever's reading has reached the end, but I'm not too experient on JavaScript, could you guys help me on that? Here's the code: <html> <title>Terra Formars</title> <link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"></link> <style> .mySlides {display:none} </style> <body> <div class="w3-container"> <h2> Leitor BETA</h2> <p>Capítulo 202 de Terra Formars.</p> </div> <div class="w3-center"> <div class="w3-section"> <button class="w3-button w3-light-grey" onclick="plusDivs(-1)">❮ Prev</button> <button class="w3-button w3-light-grey" onclick="plusDivs(1)">Next ❯</button> </div> </div> <div class="w3-content"> <img class="mySlides" src="https://i.ibb.co/fqQw2mX/00.png" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/CQ9VjsF/01.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/FVfsh9c/02.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/sq7czrk/03.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/By7k2J4/04.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/NnYp2xH/05.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/cXkgpK0/06.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/CW8fr43/07.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/LJ25GnH/08.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/Khbg5h9/09.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/wRrdp5T/10.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/TTnfdvv/11.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/72rLfpX/12.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/x8zR2yp/13.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/zXv7HJg/14.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/4tkwzt8/15.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/hHW04cS/16.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/dGx73nH/17.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/rx8G6Yr/18.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/4W1v7WS/19.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/qMYLTJz/20.jpg" style="width: 100%;" /> <img class="mySlides" src="https://i.ibb.co/3yG8h2N/22.jpg" style="width: 100%;" /> </div> <div class="w3-center"> <div class="w3-section"> <button class="w3-button w3-light-grey" onclick="plusDivs(-1)">❮ Prev</button> <button class="w3-button w3-light-grey" onclick="plusDivs(1)">Next ❯</button> </div> </div> <script> var slideIndex = 1; showDivs(slideIndex); function plusDivs(n) { showDivs(slideIndex += n); } function currentDiv(n) { showDivs(slideIndex = n); } function showDivs(n) { var i; var x = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("demo"); if (n > x.length) {slideIndex = 1} if (n < 1) {slideIndex = x.length} for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" w3-red", ""); } x[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " w3-"; } </script> </body> </html>
  18. I have referenced the W3 slideshow tutorial here and added two slideshows to my web page using Dreamweaver. I understand that the Javascript needs to be edited to accommodate 2 slideshows (divs vs. classes i think?), and I have tried to follow the instructions given here in order to edit it. Both of my slideshows seem to work independently now, but i can't figure out how to edit the Javascript to make the dots work right. The hover color works (red), but on the second slideshow, the dots do not turn red as the slideshow is advanced. I know very little about Javascript and I have gone through the Javascript tutorial, but I haven't landed on a solution. I've also searched the forums for an answer, but haven't found one that works for my specific situation. If anyone could point me toward a solution to have two slideshows on the page that both work pretty much like the one on the W3 tutorial page (with dots and arrows), I'd greatly appreciate your help — ANY guidance about how to fix the code is greatly appreciated. ~bex Here is my code: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * {box-sizing:border-box} body {font-family: Verdana,sans-serif;margin:0} .mySlides {display:none} /* Slideshow container */ .slideshow-container { max-width: 1000px; position: relative; margin: auto; } /* Next & previous buttons */ .prev, .next { cursor: pointer; position: absolute; top: 50%; width: auto; padding: 16px; margin-top: -22px; color: white; font-weight: bold; font-size: 18px; transition: 0.6s ease; border-radius: 0 3px 3px 0; } /* Position the "next button" to the right */ .next { right: 0; border-radius: 3px 0 0 3px; } /* On hover, add a black background color with a little bit see-through */ .prev:hover, .next:hover { background-color: rgba(0,0,0,0.8); } /* Caption text */ .text { color: #f2f2f2; font-size: 15px; padding: 8px 12px; position: absolute; bottom: 8px; width: 100%; text-align: center; } /* Number text (1/3 etc) */ .numbertext { color: #f2f2f2; font-size: 12px; padding: 8px 12px; position: absolute; top: 0; } /* The dots/bullets/indicators */ .dot { cursor:pointer; height: 13px; width: 13px; margin: 0 2px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease; } .active, .dot:hover { background-color: #f44336; } /* Fading animation */ .fade { -webkit-animation-name: fade; -webkit-animation-duration: 1.5s; animation-name: fade; animation-duration: 1.5s; } @-webkit-keyframes fade { from {opacity: .4} to {opacity: 1} } @keyframes fade { from {opacity: .4} to {opacity: 1} } /* On smaller screens, decrease text size */ @media only screen and (max-width: 300px) { .prev, .next,.text {font-size: 11px} } </style> </head> <body> <div id="wrapper"> <div class="slideshow w3-container w3-half"> <div class="w3-content w3-display-container"> <img class="mySlides fade" src="img_nature_wide.jpg" width="100%"> <img class="mySlides fade" src="img_fjords_wide.jpg" width="100%"> <a class="prev" onclick="plusDivs(-1, 0)">&#10094;</a> <a class="next" onclick="plusDivs(1, 0)">&#10095;</a> <!-- Extra plusDivs parameter refers to first (0) slideshow (start from 0) --> </div> <br> <div style="text-align:center"> <span class="dot" onclick="currentDiv(1)"></span> <span class="dot" onclick="currentDiv(2)"></span> </div> </div> <hr> <div class="slideshow w3-container w3-half"> <div class="w3-content w3-display-container"> <img class="mySlides fade" src="img_nature_wide.jpg" width="100%"> <img class="mySlides fade" src="img_fjords_wide.jpg" width="100%"> <a class="prev" onclick="plusDivs(-1, 1)">&#10094;</a> <a class="next" onclick="plusDivs(1, 1)">&#10095;</a> <!-- Extra plusDivs parameter refers to second (1) slideshow (start from 0) --> </div> <br> <div style="text-align:center"> <span class="dot" onclick="currentDiv(1)"></span> <span class="dot" onclick="currentDiv(2)"></span> </div> </div> <script> var slideIndex = 1; var z = document.getElementsByClassName("slideshow"); for (i = 0; i < z.length; i++) { //set custom data attribute to first current image index z[i].setAttribute("data-currentslide", 1); showDivs(z[i].getAttribute("data-currentslide"), i); } function plusDivs(n, j) { //get custom data attribute value of current image index to slideshow class index j slideIndex = parseInt(z[j].getAttribute("data-currentslide")[0]); showDivs(slideIndex += n, j); } function currentDiv(n,j) { showSlides(slideIndex += n, j); } function showDivs(n, j) { var i; var z = document.getElementsByClassName("slideshow")[j]; var x = z.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); if (n > x.length) { slideIndex = 1 } if (n < 1) { slideIndex = x.length; } //set custom data attribute to current image index z.setAttribute("data-currentslide", slideIndex); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } x[slideIndex - 1].style.display = "block"; dots[slideIndex - 1].className += " active"; } </script> </div> </body> </html>
  19. Alana

    Drop Down Panel

    Hello! I am looking for some assistance with my drop down panel. When I try to add "<div id="panel"></div> to the "select to filter by type section", it does not toggle the panel at all. Can you tell me what I am doing incorrectly? http://jsfiddle.net/AlanaVibes/xNj9z/92/#&amp;togetherjs=ROVpoPMv4L <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Checkboxradio - Default functionality</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $( function() { $( "input" ).checkboxradio(); } ); </script> </head> <body> <div class="widget"> <h1>Our Manufacturers</h1> <fieldset> <legend>Select a Territory: </legend> <label for="radio-1">All</label> <input type="radio" name="radio-1" id="radio-1"> <label for="radio-2">North Texas</label> <input type="radio" name="radio-1" id="radio-2"> <label for="radio-3">Oklahoma</label> <input type="radio" name="radio-1" id="radio-3"> <label for="radio-4">Arkansas</label> <input type="radio" name="radio-1" id="radio-4"> </fieldset> <script> &(document).ready(function(){ $("#flip").click(function(){ $("#panel").slideToggle("slow"); }); }); </script> <style> #panel, #flip { padding: 5px; text-align: left; background-color: white; border: solid 1px #c3c3c3; } #panel { padding: 50px; display: none; } </style> <div id="flip"> <h2>Type of Material</h2></div> <fieldset> <legend> Select to filter by Type </legend> <label for="checkbox-1">Wire & Cable</label> <input type="checkbox" name="checkbox-1" id="checkbox-1"> <label for="checkbox-2">Wire & Cable Accessories</label> <input type="checkbox" name="checkbox-2" id="checkbox-2"> <label for="checkbox-3">Conduit & Fittings</label> <input type="checkbox" name="checkbox-3" id="checkbox-3"> <label for="checkbox-4">Wiring Devices</label> <input type="checkbox" name="checkbox-4" id="checkbox-4"> <label for="checkbox-5">Enclosures & Wireway</label> <input type="checkbox" name="checkbox-4" id="checkbox-5"> <label for="checkbox-6">Lighting</label> <input type="checkbox" name="checkbox-4" id="checkbox-6"> <label for="checkbox-7">Fuses</label> <input type="checkbox" name="checkbox-4" id="checkbox-7"> <label for="checkbox-8">Tools & Fasteners</label> <input type="checkbox" name="checkbox-4" id="checkbox-8"> <label for="checkbox-9">Motor Control</label> <input type="checkbox" name="checkbox-4" id="checkbox-9"> <label for="checkbox-10">Specialty</label> <input type="checkbox" name="checkbox-4" id="checkbox-10"> </fieldset> </div> </body> </html>
  20. Hello people, Im stuck for a long time, I have an what older login system on my site but it had mysql but now i wanted to upgrade it to mysqli. I've came litlle by litlle bit of searcing this far but it still got error's. I really want it to work again beacause i use it on all my sites. Code: <?php // Een beveiliging om te voorkomen dat men in je header.php probeert te openen. if(basename($_SERVER['PHP_SELF']) == "header.php") { header("Location: index.php"); } // Configuratie laden include_once('config.php'); // We maken eerst een classe aan class login { // Variabelen private $loginsessie = false; public $fouten = ""; private $gebruikers_info = array(); public $database_velden = array(); private $recheck = 0; // Deze functie wordt aangeroepen bij het laden van de classe public function __construct() { // maak verbinding met de database, als het niet lukt breek het af $con = mysqli_connect(mysql_host, mysql_user, mysql_password, mysql_database) or die(mysqli_error($con)); // mysqli_select_db(mysql_database, $verbinding) or die (mysqli_error($con)); // Controlleren op een login sessie $this->check_session(); // De loguit actie koppelen aan de end_session functie if(isset($_GET['actie']) && $_GET['actie'] == 'uitloggen' && $this->loginsessie === true) { $this->end_session(); } } // Init functie public function init() { // Controlleren op een POST request, wanneer er nog geen loginsessie is if($_SERVER['REQUEST_METHOD'] == 'POST') { /* was eerst if($_SERVER['REQUEST_METHOD'] == 'POST' && $this->loginsessie===false) {*/ if(isset($_POST['actie'])) { switch($_POST['actie']) { case 'login': $this->controleer_gegevens(); break; case 'registreer_gebruiker': $this->registreer_gebruiker(); break; } } } } // Functie om het ip adres op te vragen public function get_ip() { if (isSet($_SERVER)) { if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) { $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) { $realip = $_SERVER["HTTP_CLIENT_IP"]; } else { $realip = $_SERVER["REMOTE_ADDR"]; } } else { if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) { $realip = getenv( 'HTTP_X_FORWARDED_FOR' ); } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) { $realip = getenv( 'HTTP_CLIENT_IP' ); } else { $realip = getenv( 'REMOTE_ADDR' ); } } return $realip; } private function registreer_gebruiker() { if(isset($_POST['actie']) && $_POST['actie'] == 'registreer_gebruiker') { $velden = array(); if(!is_array($this->database_velden) || !count($this->database_velden)) { die("FOUT: Geen velden opgegeven."); } // Alle velden uit de array doorlopen foreach($this->database_velden as $veld) { $veld = split(':', $veld); // Veldnaam $veld_naam = $veld[0]; $velden[$veld_naam] = $_POST[$veld_naam]; // Veld instellingen $veld_instellingen = split('\|', $veld[1]); foreach($veld_instellingen as $instelling) { if($instelling == 'verplicht' && empty($velden[$veld_naam])) { // Controlleer of het veld is ingevuld $this->fouten .= "- Het veld '". $veld_naam ."' is verplicht<br />"; } elseif($instelling == 'md5') { // Codeer naar md5 $velden[$veld_naam] = md5($velden[$veld_naam]); } elseif(substr($instelling, 0, 3) == 'min') { // Controlleer minimum stringlengte if(strlen($velden[$veld_naam]) < (int) substr($instelling, 4)) { $this->fouten .= "- Het veld '". $veld_naam ."' is te kort.<br />"; } } elseif(substr($instelling, 0, 3) == 'max') { // Controleer maximum stringlengte if(strlen($velden[$veld_naam]) > (int) substr($instelling, 4)) { $this->fouten .= "- Het veld '". $veld_naam ."' is te lang.<br />"; } } elseif(substr($instelling, 0, 2) == "==") { if($velden[$veld_naam] != $_POST[substr($instelling, 2)]) { $this->fouten .= '- De velden '. $veld_naam .' en '. substr($instelling, 2) .' komen niet overeen.<br />'; } } elseif($instelling == "avatar") { $velden[$veld_naam] = ('http://habmoon.org/status/habbie?habbie='.$_POST["gebruikersnaam"].'&direction=4&head_direction=3&action=wlk&gesture=sml&size=b'); } elseif($instelling == 'uniek') { $q = mysqli_query($this->con,"SELECT ". $veld_naam ." FROM gebruikers WHERE ". $veld_naam ." = '". mysqli_real_escape_string($this->con, $velden[$veld_naam]) ."' "); if(!$q) { $this->fouten .= '- Er is een MySQL fout opgetreden <br />'; } else { if(mysqli_num_rows($q)) { $this->fouten .= 'De inhoud van veld '. $veld_naam .' bestaat al<br />'; } } } elseif($instelling == 'email') { // Controleer email if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $velden[$veld_naam])) { $this->fouten .= "- Het email is incorrect.<br />"; } } } } if(!$this->fouten) { // SQL genereren $SQL = "INSERT INTO gebruikers "; $SQL_TMP = ""; foreach($velden as $key=>$value) { $SQL_TMP .= ", ". $key ." = '". mysqli_real_escape_string($this->con, $value) ."' "; } // Eerste komma weghalen $SQL .= "SET ".preg_replace("#^,{0,1}#", '', $SQL_TMP); if($SQL_TMP && mysqli_query($this->con,$SQL)) { header("Location: ../index.php"); } else { $this->fouten = "Er is een MySQL fout opgetreden."; /* om te debuggen gebruik: die(mysqli_error($con)); */ } } } } // Functie om gegevens te controleren private function controleer_gegevens() { // Kijken of we het juiste formulier gebruiken if(isset($_POST['actie']) && $_POST['actie'] == 'login') { // Gegevens van formulier opvragen en escapen tegen mysql injectie $gebruiker = mysqli_real_escape_string($this->con, $_POST['gebruikersnaam']); $wachtwoord = mysqli_real_escape_string($this->con, $_POST['wachtwoord']); // Kijken of we MD5 moeten gebruiken (zie configuratie bestand) if(login_password_md5===true) { $wachtwoord = md5($wachtwoord); } // Kijken of de gegevens correct zijn $query = mysqli_query($this->con,"SELECT * FROM gebruikers WHERE gebruikersnaam = '". $gebruiker ."' AND wachtwoord = '". $wachtwoord ."'"); if(mysqli_num_rows($query)) { // Array gebruikersinfo maken $this->gebruikersinfo = array(); $this->gebruikersinfo['info'] = mysqli_fetch_array($query); // Start sessie return $this->start_session(); } else { // Kijken wat er mis ging: if(mysqli_error($this->con)) { $this->fouten = "Er is een mysql fout opgetreden."; } else { $this->fouten = "Gebruiksnaam en/of wachtwoord is incorrect."; } } } } // Functie om de sessie te controlleren private function check_session() { // Controleren op cookie if($this->recheck>=3) { $this->fouten = "Er is een ongeldige cookie sleutel gevonden die niet kon worden verwijderd."; return false; } if(isset($_COOKIE['sid']) && !empty($_COOKIE['sid'])) { // Er is een niet-lege cookie $sid = mysqli_real_escape_string($this->con, $_COOKIE['sid']); // Controleren of sleutel en ip aanwezig zijn in database $query = mysqli_query($this->con,"SELECT * FROM logins WHERE sid = '". $sid ."' AND ip = '". $this->get_ip() ."'") or die("Er is een fout opgetreden."); if(mysqli_num_rows($query)) { $f = mysqli_fetch_array($query); // Gegevens uit database ophalen $query = mysqli_query($this->con,"SELECT * FROM gebruikers WHERE id = '". $f['uid'] ."' "); if(mysqli_num_rows($query)) { $this->loginsessie = true; $this->gebruikersinfo = array(); $this->gebruikersinfo['info'] = mysqli_fetch_array($query); } } } else { // Er is een ongeldige sleutel gevonden, laten we die eens verwijderen $secondes = login_session_time * 3600; setcookie("sid", "", time()-$secondes, "/"); $this->recheck = $this->recheck + 1; } } // De functie om de login sessie te starten private function start_session() { // Unieke sleutel maken $this->gebruikersinfo['sleutel'] = md5(rand(0,99999999999).date("dmyhis")); // Informatie invoegen in database $info = $this->gebruikersinfo['info']; $SQL = "INSERT INTO logins "; $SQL .= "SET uid = '". mysqli_real_escape_string($this->con, $info['id']) ."' "; $SQL .= ", sid = '". mysqli_real_escape_string($this->con, $this->gebruikersinfo['sleutel']) ."' "; $SQL .= ", ip = '". mysqli_real_escape_string($this->con, $this->get_ip()) ."' "; $SQL .= ", datum = NOW() "; mysqli_query($this->con,$SQL) or die("Error: kon niet inloggen."); // Secondes maken van uren, zie configuratie bestand $secondes = login_session_time * 3600; setcookie("sid", $this->gebruikersinfo['sleutel'], time()+$secondes, "/"); // Verversing header("Location: ".$_SERVER['REQUEST_URI']); } private function end_session() { // index.php?actie=uitloggen // Verwijder sessie mysqli_query($this->con,"DELETE FROM logins WHERE sid = '". $_COOKIE['sid'] ."' AND ip = '". $this->get_ip() ."'") or die("Er is een fout opgetreden."); // verwijder cookie $secondes = login_session_time * 3600; setcookie("sid", "", time()-$secondes, "/"); // Redirect $url = str_replace("actie=uitloggen", "", $_SERVER['REQUEST_URI']); // haal de actie weg header("Location: ".$url); } // Functie om gegevens op te vragen public function get_login_info($wat=false) { // Is er iets aanwezig? if(!$this->loginsessie || !count($this->gebruikersinfo)) { return false; } else { if($wat==='alles') { return $this->gebruikersinfo['info']; } elseif(isset($this->gebruikersinfo['info'][$wat])) { return $this->gebruikersinfo['info'][$wat]; } else { return true; } } } } // Class starten $login = new login(); $login->database_velden = array( /* Velden waarvan de value in de database komt. Plaats die in de database en formulier. Syntax: veldnaam:instellingen Instellingen scheiden met '|'. Instellingen: 'verplicht': [string] Verplicht veld. 'min=int': [int] Minimum aantal karakters dat is vereist. 'max=int': [int] Maximum aantal karakters dat is vereist. '==veldnaam': [string] waarde van dit veld moet overeenkomen met 'veldnaam'. 'md5': [string] Codeer met md5. MOET als laatste. */ 'gebruikersnaam:verplicht|uniek|min=3|max=15|', 'rank:max=15|', 'email:max=100|email|', 'avatar:max=100|avatar|', 'wachtwoord:verplicht|min=3|max=16|==wachtwoord2|md5|' /* was eerst 'wachtwoord:verplicht|min=3|max=16|==wachtwoord2'*/ ); $login->init(); ?> Error: Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 157 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 157 Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 158 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 158 Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 166 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 166 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\Admin\header.php on line 167 Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 176 Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 176
  21. Hay can someone offer some input(it's definitely not mobile friendly what I wrote) in regards to JavaScript and the html form document, I can't recalls the relationship while testing the JavaScript logic, any inputs welcome. Definitely recommend looking at it via desktop mode if on tablet or phone. 🤗 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> </head> <body> <!--FORM_REGISTER--> <div class="one"> <form action=" " method="post" onsubmit = "return register_details();" /> <!--C--> Country<br><input type="text"id="country"/></br> <!--A--> Age<br><input type="age"id="DOB"/></br> <!--S--> Status<br><input type="text"id="status"/></br> </form> </div> <div class="two"> <form action="submission.html" method="register_details(id)" onsubmit = "return register_details();" /> <!--U-->UserName<br><input type="text" value="" id="UsernName"/></br> <!--P-->Password<br><input type="password"value="" id="Password"/></br> <!--E--> Email<br><input type="Email" value="" id="Email"/></br> Male<br><input type="radio" value="" id="male" /></br> Female<br><input type="radio" value="female" id="female" /></br> Submit<br><input type="submit" value="register" id ="submit "/></br> </form> </div> <style type="text/css"> .one { background-color:#444444; color:white; margin:350px; padding:12px; text-align:left; position:fixed; } .two { background-color:#444444; color:white; margin:350px; padding:12px; text-align:center; position:fixed; left:10px; top:240px; width:1157px; height:1000px; background:#444444; } //body { overflow:hidden; } </style> <!-----------------------------------------------> <script type="text/javascript"> function register_details(id) { // bool checked = false; var username = document.getElementById (id,value,"username").value; var password = document.getElementById (id,"password").value; var email = document.getElementById (id,"email").value; var male = document.getElementById (id,"male").value; var female = document.getElementById (id,"female").value; <!------------------------------------------------------> var submit = document.getElementById (id,"register").value; if ((value === "") || (password === "") || (email === "")) { alert("please correct information"); }if ((male[0].checked === false ) && ( female[1].checked === false )){ console.log("please fix gender"); } else if (ErrorText= "") { alert("please correct information"); }else{ submit(register_details(id)) } } </script> <!------------------------------------------------> </body> </body> </html>
  22. Hi everyone. Before I want to say, Im trying to make a project Raspberry PI 3 and Nodered. I'm logging my data from device to Litesql everything is ok. I just want to take this data from db and make a chart for a specific time, like today, yesterday, last week, last mont, last year. I found a code, and need to change this code for my project in javascript. Can some one help me. My db name is Test and column name is Value This code is working code, which is I take in internet , and I changed just db name and source. // This will handle any device and any attribute as long as it is in the DB var p_30d = 1000*60*60*24*30 ; //30 Days var p_7d = 1000*60*60*24*7 ; //7 Days var p_1d = 1000*60*60*24 ; // 1 Day var d = new Date(); var current = d.getTime(); var today0h = d.setHours(0,0,0,0); var day = d.getDay(); var monday0h = today0h - (day + (day === 0 ? -6:1)) * p_1d; var fromdate = 0; var enddate = 0; var sql = []; var sourcelist = []; var aggrlist = []; var title = ""; // Get the period and the list of data sources // also set some default values if one or the other does not exist yet sourcelist = context.get("sourcelist"); if (sourcelist===undefined) { // if running for the first time sourcelist = []; } aggrlist = context.get("aggrlist"); if (aggrlist===undefined) { // if running for the first time aggrlist = []; } fromdate = context.get("fromdate"); if (fromdate===undefined) { // set the period to a default if it is not selected yet fromdate = current-p_1d; } enddate = context.get("enddate"); if (enddate===undefined) { // set the period to a default if it is not selected yet enddate = current; } switch(msg.topic) { case "period": switch(msg.payload) { case "today": fromdate = today0h; enddate = today0h+p_1d; break; case "yesterday": fromdate = today0h-p_1d; enddate = today0h; break; case "thisweek": fromdate = monday0h; enddate = monday0h+p_7d; break; case "lastweek": fromdate = monday0h-p_7d; enddate = monday0h; break; case "last24h": fromdate = current-p_1d; enddate = current; break; case "last7d": fromdate = current-p_7d; enddate = current; break; case "last30d": fromdate = current-p_30d; enddate = current; break; } context.set("fromdate",fromdate); context.set("enddate",enddate); break; case "datasource": if (msg.payload==="delete") { // remove all previous data sources sourcelist = []; } else { sourcelist = context.get("sourcelist"); if (sourcelist===undefined) { // if running for the first time sourcelist = []; } sourcelist.push(msg.payload); } context.set("sourcelist",sourcelist); break; case "aggrsource": if (msg.payload==="delete") { // remove all previous data sources aggrlist = []; } else { aggrlist = context.get("aggrlist"); if (aggrlist===undefined) { // if running for the first time aggrlist = []; } aggrlist.push(msg.payload); } context.set("aggrlist",aggrlist); break; case "minus1w": fromdate = fromdate-p_7d; enddate = enddate-p_7d; context.set("fromdate",fromdate); context.set("enddate",enddate); break; case "plus1w": fromdate = fromdate+p_7d; enddate = enddate+p_7d; context.set("fromdate",fromdate); context.set("enddate",enddate); break; case "minus1d": fromdate = fromdate-p_1d; enddate = enddate-p_1d; context.set("fromdate",fromdate); context.set("enddate",enddate); break; case "plus1d": fromdate = fromdate+p_1d; enddate = enddate+p_1d; context.set("fromdate",fromdate); context.set("enddate",enddate); break; } // Regenerate the SQL statements // Run through the data source list an generate the SQL statements sql = []; if (sourcelist.length>0) { for (var i = 0; i < sourcelist.length; i++) { var parts = sourcelist[i].split("/"); sql.push({ topic: "SELECT * FROM sensor_data WHERE device='"+parts[0]+"' AND sensor='"+parts[1]+"' AND epoch >= " + fromdate + " AND epoch <= " + enddate }); } } if (aggrlist.length>0) { for (var i = 0; i < aggrlist.length; i++) { var parts = aggrlist[i].split("/"); sql.push({ topic: "SELECT * FROM sensor_aggr WHERE device='"+parts[0]+"' AND sensor='"+parts[1]+"' AND epoch >= " + fromdate + " AND epoch <= " + enddate }); } } if (sql.length===0) { // Dummy select that returns nothing to clear the chart sql.push({ topic: "SELECT * FROM sensor_data WHERE device='xxxx'" }); } // set the completed flag for the join node later sql[sql.length-1].complete=true; // pass along the email flag to redirect the flow later if (msg.topic==="email") { sql[sql.length-1].email=true; } // Generate report title if (sourcelist.length===0 && aggrlist.length===0) { title = "No data source"; } else { if (sourcelist.length!==0) { title = title + sourcelist.toString()+ ", "; } if (aggrlist.length!==0) { title = title + aggrlist.toString()+ ", "; } title = title.substring(0,title.length-2); title = title + " | "; var d = new Date(); d.setTime(fromdate); var yyyy = d.getFullYear(); var mm = d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : (d.getMonth() + 1); // getMonth() is zero-based var dd = d.getDate() < 10 ? "0" + d.getDate() : d.getDate(); var hh = d.getHours() < 10 ? "0" + d.getHours() : d.getHours(); var mmm = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes(); var ss = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds(); title = title + dd + "." + mm + "." + yyyy; d.setTime(enddate); yyyy = d.getFullYear(); mm = d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : (d.getMonth() + 1); // getMonth() is zero-based dd = d.getDate() < 10 ? "0" + d.getDate() : d.getDate(); hh = d.getHours() < 10 ? "0" + d.getHours() : d.getHours(); mmm = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes(); ss = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds(); title = title + " - " + dd + "." + mm + "." + yyyy; } sql[sql.length-1].title=title; return [ sql ]; This is I changed code but not working. // This will handle any device and any attribute as long as it is in the DB var p_30d = 1000*60*60*24*30 ; //30 Days var p_7d = 1000*60*60*24*7 ; //7 Days var p_1d = 1000*60*60*24 ; // 1 Day var d = new Date(); var current = d.getTime(); var today0h = d.setHours(0,0,0,0); var day = d.getDay(); var monday0h = today0h - (day + (day === 0 ? -6:1)) * p_1d; var fromdate = 0; var enddate = 0; var sql = []; //var sourcelist = []; var aggrlist = []; var title = ""; // Get the period and the list of data sources // also set some default values if one or the other does not exist yet sourcelist = context.get("sourcelist"); if (sourcelist===undefined) { // if running for the first time sourcelist = []; } aggrlist = context.get("aggrlist"); if (aggrlist===undefined) { // if running for the first time aggrlist = []; } fromdate = context.get("fromdate"); if (fromdate===undefined) { // set the period to a default if it is not selected yet fromdate = current-p_1d; } enddate = context.get("enddate"); if (enddate===undefined) { // set the period to a default if it is not selected yet enddate = current; } switch(msg.topic) { case "period": switch(msg.payload) { case "today": fromdate = today0h; enddate = today0h+p_1d; break; case "yesterday": fromdate = today0h-p_1d; enddate = today0h; break; case "thisweek": fromdate = monday0h; enddate = monday0h+p_7d; break; case "lastweek": fromdate = monday0h-p_7d; enddate = monday0h; break; case "last24h": fromdate = current-p_1d; enddate = current; break; case "last7d": fromdate = current-p_7d; enddate = current; break; case "last30d": fromdate = current-p_30d; enddate = current; break; } context.set("fromdate",fromdate); context.set("enddate",enddate); break; case "datasource": if (msg.payload==="delete") { // remove all previous data sources sourcelist = []; } else { sourcelist = context.get("sourcelist"); if (sourcelist===undefined) { // if running for the first time sourcelist = []; } sourcelist.push(msg.payload); } context.set("sourcelist",sourcelist); break; case "aggrsource": if (msg.payload==="delete") { // remove all previous data sources aggrlist = []; } else { aggrlist = context.get("aggrlist"); if (aggrlist===undefined) { // if running for the first time aggrlist = []; } aggrlist.push(msg.payload); } context.set("aggrlist",aggrlist); break; } // Regenerate the SQL statements // Run through the data source list an generate the SQL statements sql = []; if (sourcelist.length>0) { for (var i = 0; i < sourcelist.length; i++) { var parts = sourcelist[i].split("/"); sql.push({ topic: "SELECT Value FROM Test" +value[0]+""+value[1]+ fromdate + " " + enddate }); } } //if (aggrlist.length>0) { // for (var i = 0; i < aggrlist.length; i++) { // var parts = aggrlist[i].split("/"); // sql.push({ topic: "SELECT Value FROM Test" +value[0]+""+value[1] + fromdate + " " + enddate }); // } //} if (sql.length===0) { // Dummy select that returns nothing to clear the chart sql.push({ topic: "SELECT Value FROM Test" }); } // set the completed flag for the join node later sql[sql.length-1].complete=true; // pass along the email flag to redirect the flow later if (msg.topic==="email") { sql[sql.length-1].email=true; } // Generate report title if (sourcelist.length===0 && aggrlist.length===0) { title = "No data source"; } else { if (sourcelist.length!==0) { title = title + sourcelist.toString()+ ", "; } if (aggrlist.length!==0) { title = title + aggrlist.toString()+ ", "; } title = title.substring(0,title.length-2); title = title + " | "; var d = new Date(); d.setTime(fromdate); var yyyy = d.getFullYear(); var mm = d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : (d.getMonth() + 1); // getMonth() is zero-based var dd = d.getDate() < 10 ? "0" + d.getDate() : d.getDate(); var hh = d.getHours() < 10 ? "0" + d.getHours() : d.getHours(); var mmm = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes(); var ss = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds(); title = title + dd + "." + mm + "." + yyyy; d.setTime(enddate); yyyy = d.getFullYear(); mm = d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : (d.getMonth() + 1); // getMonth() is zero-based dd = d.getDate() < 10 ? "0" + d.getDate() : d.getDate(); hh = d.getHours() < 10 ? "0" + d.getHours() : d.getHours(); mmm = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes(); ss = d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds(); title = title + " - " + dd + "." + mm + "." + yyyy; } sql[sql.length-1].title=title; return [ sql ];
  23. Hi everyone, I'm trying to create the look like "paginate data page", but it is not. I set up the file to insert in website by iframe, but I need to find a way to make clicked data like click the checkbox, then click on next, go to next file in iframe, then come back, stay checked in checkbox. Do you understand what I mean? I'm not fluent in English, my prime is American Sign Language.
  24. Hello potential helpers, im currently having issues with firing an ajax request inside of another ajax request. Heres my code: Im not getting "alert(content)" Condition if(shop[1] == "gserver") and if(name.includes(shopname) == true) are definetly true. The function is correctly called as well. No Im not using jquery for reasons. Anyone has an idea why the 2nd requests isnt fired? Is it not waiting for the first one to finish? function initiate_shop_game(shopname) { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if(this.readyState == 4 && this.status == 200) { var obj = this.responseText; var array = eval("[" + obj + "]"); var r = 1; for(var i = 0; i < array.length; i++) { for(var x = 0; x < array[i].length; x++) { var shop = array[i][x] + ''; shop = shop.split(","); if(shop[1] == "gserver") { var name = shop[2]; var imgname = shop[7] var shopvalues = shop[3].split("{%TEND%}"); var minslots = parseInt(shopvalues[1]); var maxslots = parseInt(shopvalues[2]); var minram= parseInt(shopvalues[3]); var maxram = parseInt(shopvalues[4]); var pricea = (parseFloat(shop[5]) / 30); var priceb = (parseFloat(shop[6] / 30)); var content = [name,imgname,minslots,maxslots,minram,maxram,pricea,priceb]; if(name.includes(shopname) == true) { var div = document.createElement('div'); div.id = name; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { alert(content); }; xmlhttp.open('POST',"/template_shop.php", true); xmlhttp.send(); } } } } } } }; xmlhttp.open('POST',"/get_shop_data.php", true); xmlhttp.send(); }
  25. CONCERN: The following function does what it is suppose to do -- namely, select at random and without duplication a given number of elements from an array of elements. However, I fear that it is hopelessly awkward and would like your professional assessment of its construction. You will likely not find another like it on the internet, but parts of it were obtained therefrom. function selectCubes(gates) { function onlyUnique(value, index, self) { return self.indexOf(value) === index; } var cubes = ['cube_one', 'cube_two', 'cube_three', 'cube_four', 'cube_five', 'cube_six', 'cube_seven']; var selectedCubes = []; var filteredCubes = []; var n = 0; while (n < gates) { selectedCube = cubes[Math.floor(Math.random()*cubes.length)]; selectedCubes.push(selectedCube); if (filteredCubes.length < gates) { var filteredCubes = selectedCubes.filter(onlyUnique); n++; } } return filteredCubes; } console.log('selectCubes(3):' + selectCubes(3)); Please comment and have a great weekend! Roddy
×
×
  • Create New...