Jump to content

Search the Community

Showing results for tags 'function'.



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

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 55 results

  1. hey specialists, i spent 2 days on a small java-calulating script for my 7 year old son, to "play on the tablet" :-). At the moment he is not allowed to play games, so he can practice math a little bit... i don't use an app, because i like the "challange" and want to learn something too. thats why i startet to try coding. Now i cant go on, the check-button in my script doesn't do anything. My script shows tasks an Operators, but the entered solution is not going to be compared with the result. Can someone help me to find the error? Script in action is here: http://holland-nell.net/php/java-rechnen.html the Code was written easily in "german". i translated the comments in english... Thanks :-) <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=2.0"> <title>Titel</title> <style> #box { width:400px; } </style> <script> var min = 5, max = 10; var richtig = 0, falsch = 0; function hilfe() { /* show result in red */ document.getElementById("erg-output").style.color = "red"; /* Using Help Button is like a not solved task*/ falsch++; document.getElementById("falsch").innerHTML = falsch; /* Reset Inputfield */ document.ergebnis.ergebnis_eingabe.value =""; /* neue Aufgabe nach 1,5 Sekunden */ sleep(1500); aufgabe_erstellen(min,max); } function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } function compare () { /* compare entered and calculated value */ var erg_eingabe = (document.ergebnis.ergebnis_eingabe.value); var erg =(document.getElementById("erg-output").value); console.log('Ergebnis Eingabe: ' + erg_eingabe + ' berechnetes Ergebnis: ' + erg); if (erg == erg_eingabe) { alert("richtig"); document.ergebnis.ergebnis_eingabe.value =""; richtig++; document.getElementById("richtig").innerHTML = richtig; } else { alert("falsch"); falsch++; document.getElementById("falsch").innerHTML = falsch; } } function aufgabe_erstellen(min, max) { /* show result in white */ document.getElementById("erg-output").style.color = "white"; /* if input empty create new task */ if(document.ergebnis.ergebnis_eingabe.value == '') { zahl1 = Math.floor(Math.random() * (max - min +1)) + min; zahl2 = Math.floor(Math.random() * (max - min +1)) + min; /* check which operation is activeted */ var op =''; for (var i = 0; i < 4; i++) { if(document.operatoren.op[i].checked) { op = (document.operatoren.op[i].value); break; } } /* Create a String to show in div-element */ var aufgabe = zahl1 + ' ' + op + ' ' + zahl2; eval(aufgabe); /* Calc results */ switch (op) { case '+': var erg = zahl1 + zahl2; break; case '-': erg = zahl1 - zahl2; break; case '*': erg = zahl1 * zahl2; break; case '/': erg = zahl1 / zahl2; break; default: erg = ''; } /* Show task and result (in white) */ document.getElementById("aufgabe").innerHTML = aufgabe + " = "; document.getElementById("erg-output").innerHTML = erg; /* if inputfield not empty call function "compare" */ } else { compare(); } } </script> </head> <body> <div id="box"> <div class=""> <form name="operatoren" onchange="aufgabe_erstellen(min,max)"> <input type="radio" name="op" value="-">Minus</input> <input type="radio" name="op" value="+">Plus</input> <input type="radio" name="op" value="*">Multiplikation</input> <input type="radio" name="op" value="/">Division</input> </form> <div id="aufgabe"></div><div id="erg-output"></div> </div> <div class=""> <form name="ergebnis"> <input type="number" name="ergebnis_eingabe" /> </form> <button onklick="compare()">Check</button> </div> <div> <button onclick="hilfe()">Hilfe?</button><br> Richtig: <div id="richtig">0</div> Falsch: <div id="falsch">0</div> </div> </div> </body> </html>
  2. Woocommerce took out the option for enabling a lightbox feature for your image gallery earlier this year. They have in their documentation to add code if you want to enable the gallery features but don’t actually say where. https://woocommerce.wordpress.com/2017/02/28/adding-support-for-woocommerce-2-7s-new-gallery-feature-to-your-theme/ This is a significant frontend change that can be broken down in to three separate new features; Image zoom / magnification Lightbox Slider To enable each of these features in your theme you must declare support using add_theme_support() like so; 1 2 3 4 5 6 7 add_action( 'after_setup_theme', 'yourtheme_setup' ); function yourtheme_setup() { add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); } This allows you the flexibility to pick and choose exactly which features you want to include/exclude in your theme or at your store. I am not a developer, I don’t have a developer (and shame on WC for not making this an option that end users can opt for or not without having to add code!) I need to know where to put this code. I am using a child theme called mystile1. I have files called “Theme Functions (function.php)” and one called “custom.css” that’s says it is specifically for adding code to modify my child theme styles. I don’t know which file I should put the above coding in and where. Nowhere does each of these files have a line called “after_setup_theme” So would I be safe in just adding the code as follows in one of those files (which one?) replacing “yourtheme” with the name of my theme: add_action( 'after_setup_theme', 'mystile1_setup' ); function mystile1_setup() { add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); } Or any other suggestions are greatly appreciated. Thank you.
  3. So I am working on a simple client database type program. I have a clients array that stores new clients that all have a first name, last name, phone number, etc... I also want the user to be able to add notes about their clients' family. So, one of the parameters of the client function is an array called familyNotes. Here is the code for this: function client(firstName, lastName, phoneNumber, address, hireDate, frequency, cost, entry, familyNotes) { this.firstName = firstName; this.lastName = lastName; this.phoneNumber = phoneNumber; this.address = address; this.hireDate = hireDate; this.frequency = frequency; this.cost = cost; this.entry = entry; this.familyNotes - familyNotes; } var laura = new client("laura", "simmerman", "1111111111", "laura rd", "01/01/01", "weekly", "100", "garage-1111"); var jana = new client("jana", "simmerman", "2222222222", "jana rd", "01/01/01", "weekly", "100", "garage-2222"); var clients = [laura, jana]; However, I do not know if the familyNotes array is working properly. I have a function that prompts the user to add a note about the family of a client, then adds the note to the array. Here is the code for this function: function addFamilyNotes(i) { var note = prompt("Add a note about the family: "); document.getElementById("familyNotes").innerHTML += "<li>" + note + "</li>"; clients[i].familyNotes.push(note); } I later have a function that is supposed to alert the length of the familyNotes array, however it doesn't alert anything currently. Here is the code: function familyNotesAlert(i) { alert(clients[i].familyNotes.length); } Does anyone know what I am doing wrong? Why is the alert not showing, and is anything actually being added to the familyNotes array?
  4. I've got a function that create mesh when you click on another. On the click, 2 or 3 mesh are created and go to their positions. Know i would like to do the reverse function : when the mesh are deployed, and you click anoter time on the mesh, the previously created mesh go back and are removed from the scene. Here is my first function : function sortiSphere(element, obj) { var matStdParams = { roughness: 1, metalness: 0.8, color: element.group, emissive: element.group, emissiveIntensity: 0.5 }; var sphereMaterial2 = new THREE.MeshStandardMaterial(matStdParams); var mesh = new THREE.Mesh(sphereGeometry, sphereMaterial2); mesh.position.x = x; mesh.position.y = y; mesh.position.z = z; mesh.userData.children = element.children; mesh.userData.name = element.label; mesh.userData.rang = element.rang; mesh.userData.def = element.définition; mesh.userData.posx = element.posx; mesh.userData.posy = element.posy; mesh.userData.posz = element.posz; mesh.userData.parent = obj; mesh.userData.cartabs = element.cartabs; mesh.position.normalize(); mesh.position.multiplyScalar(1 / element.rang); mesh.scale.set(1 / (element.rang / 2), 1 / (element.rang / 2), 1 / (element.rang / 2)) mesh.position.x = obj.position.x; mesh.position.y = obj.position.y; mesh.position.z = obj.position.z; var x = element.posx; var y = element.posy; var z = element.posz; new TWEEN.Tween(mesh.position).to({ x: x, y: y, z: z }, 1000) .easing(TWEEN.Easing.Elastic.Out).start(); console.log(mesh); scene.add(mesh); lesMesh.push(mesh) // lines var material = new THREE.LineBasicMaterial({ color: 0xffffff }); var geometry = new THREE.Geometry(); geometry.vertices.push( obj.position, new THREE.Vector3(x, y, z) ); var line = new THREE.Line(geometry, material); scene.add(line); gen1 = []; gen2 = []; gen3 = []; gen4 = []; gen5 = []; obj.userData.bool = true; }; Notice that the mesh contain a information about their state : userData.bool (true if deployed, false if not) Now, how do I tell them to go back ? Here is what I got for now : function deleteSphere(element, obj) { console.log("--- deleteSphere / debut fonction") for (i = 0; gen1.length > i; i++) { if (gen1[i].userData.children) { for (j = 0; gen1[i].userData.children.length > j; j++) { console.log(gen2[i][j]); scene.remove(gen2[i][j]);} } else { scene.remove(gen1[i]) console.log(gen1[i].userData.children) } } }; Thanks for your time
  5. placing a function inside an if condition

    Sorry people here I have asked this before, so its a bit embarassing to me. But .... I have the following question. Its about using a function inside an if condition. The thing is that when I make a function with 2 returns in this case $data and $alternative I receive them both back. I ask this for grasping how a function acts inside an if condition. So my question is: how does the php engine ‘reason’? Is the outcome of the return ONLY POSSIBLE if you return 1 value inside an if condition; so either true or false ? Example: <?php function valid_someting($data){ global $alternative; $count=''; $count = strlen($data); if ( ($count < 8 && ($count > 4) ) ) { $data = preg_replace('/[^a-zA-Z0-9!@#$%^&*()\-_=+{};:,<.>]/', '', $data ); // $data = ltrim($data); $data = rtrim($data); return $data; } $alternative = $data; return $alternative; } $data = 'abcdabcdabcd'; if (valid_someting($data)) { echo 'color input field green'; } else if ($alternative == TRUE) { echo 'color input field RED'; } ?>
  6. [SOLVED]
  7. fetch multiple rows outside function

    Hi All, I'm looking for a solution in using a function. The function fetches data from a database. In a column multiple results are found. I want to have all the records outisde the function. Inside the function all records are shown, but outside only the last record. I thought I could use return array, but it only returns multiple variables and not multiple rows. Not sure if fetch() is the solution for arrays. example: <?php function test_func($val4) { global $val1; global $val2; global $val4; $servername = "host"; $username = "johndoe"; $password = "admin"; $dbname = "dbase_db"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // if ($stmt = $conn->prepare("SELECT col1, col2 FROM table WHERE col4 = ? ; ")) { $stmt->bind_param("s", $val4); $stmt->execute(); $stmt->store_result(); $num_of_rows = $stmt->num_rows; var_dump($num_of_rows); $stmt->bind_result($val1, $val2); if ($num_of_rows > 0){ while ($stmt->fetch()) { // managed to output multiple rows here, but that's not the goal } return array ($val1, $val2); } } } $val4='form_value'; test_func($val4); // return multiple rows here, outside the function How should I solve this?
  8. Having problem with positioning

    Hi, here is a code. I want to make the .characteristics-quote to stay fixed when scrolling to the .characteristics-wrapper. But When the characteristics-wrapper class scrolling is finished the .characteristics-quote should be vanished. Can you please tell me how I can fix this ? Thank you in advance. <!DOCTYPE html> <html lang= "en-us"> <head> <meta charset= "utf-8"/> <title>About</title> <link rel= "stylesheet" type= "text/css" href= "font-awesome-4.7.0/css/font-awesome.min.css"/> <style type= "text/css"> body { margin: 0; padding: 0; color: white; background-color: black; overflow: auto; } .about { max-width: 100%; height: 200px; background-color: black; color: white; text-align: center; padding-left: 10%; padding-right: 10%; padding-top: 5px; margin: 0; } .characteristics-wrapper { max-width: 100%; padding: 10px; margin-bottom: 200px; border: 1px solid white; overflow: hidden; } .characteristics-quote { max-width: 40%; float: left; transform: translateX(-5%); position: fixed; color: white; } .characteristics-quote h1 { max-width: 70%; text-align: center; margin: auto; padding-top: 100px; } .characteristics-container { max-width: 60%; float: right; text-align: center; position: relative; } .characteristics-item-row1, .characteristics-item-row2 { max-width: 50%; } .characteristics-item-row1 { padding-top: 50px; } .characteristics-item-row2 { position: absolute; top:50px; right: 0; } .characteristics-item { max-width: 80%; display: block; margin: auto; margin-bottom: 20px; margin-top: 20px; } .characteristics-icon { font-size: 60px; padding: 15px; border: 1px solid lightgrey; border-radius: 50%; height: 76px; width: 76px; margin: auto; } .characteristics-item:hover .characteristics-icon{ background-color: white; color: black; -webkit-transition: 0.6s ease-in-out; -moz-transition: 0.6s ease-in-out; -ms-transition: 0.6s ease-in-out; -o-transition: 0.6s ease-in-out; transition: 0.6s ease-in-out; } /**Animations**/ .left { -webkit-animation-name: left; -webkit-animation-duration: 1s; -moz-animation-name: left; -moz-animation-duration: 1s; -ms-animation-name: left; -ms-animation-duration: 1s; -o-animation-name: left; -o-animation-duration: 1s; animation-name: left; animation-duration: 1s; } .right { -webkit-animation-name: right; -webkit-animation-duration: 3s; -moz-animation-name: right; -moz-animation-duration: 3s; -ms-animation-name: rightt; -ms-animation-duration: 3s; -o-animation-name: right; -o-animation-duration: 3s; animation-name: right; animation-duration: 3s; } .scale { -webkit-animation-name: scale; -webkit-animation-duration: 2s; -moz-animation-name: fade; -moz-animation-duration: 2s; -ms-animation-name: scale; -ms-animation-duration: 2s; -o-animation-name: scale; -o-animation-duration: 2s; animation-name: scale; animation-duration: 2s; } .fade { -webkit-animation-name: fade; -webkit-animation-duration: 2s; -moz-animation-name: fade; -moz-animation-duration: 2s; -ms-animation-name: fade; -ms-animation-duration: 2s; -o-animation-name: fade; -o-animation-duration: 2s; animation-name: fade; animation-duration: 2s; } /**Animating from the left**/ @-webkit-keyframes left { from {left: -500px;} to {left: 0;} } @-moz-keyframes left { from {left: -500px;} to {left: 0;} } @-ms-keyframes left { from {left: -500px;} to {left: 0;} } @-o-keyframes left { from {left: -500px;} to {left: 0;} } @keyframes left { from {left: -500px;} to {left: 0;} } /**Animating from the right**/ @-webkit-keyframes right { from {right: -500px;} to {right: 0;} } @-moz-keyframes right { from {right: -500px;} to {right: 0;} } @-ms-keyframes right { from {right: -500px;} to {right: 0;} } @-o-keyframes right { from {right: -500px;} to {right: 0;} } @keyframes right { from {right: -500px;} to {right: 0;} } /**Animating scale**/ @-webkit-keyframes scale { from {transform: scale(3);} to {transform: scale(1);} }@-moz-keyframes scale { from {transform: scale(3);} to {transform: scale(1);} }@-ms-keyframes scale { from {transform: scale(3);} to {transform: scale(1);} }@-o-keyframes scale { from {transform: scale(3);} to {transform: scale(1);} } @keyframes scale { from {transform: scale(3);} to {transform: scale(1);} } /**Fading animation**/ @-webkit-keyframes fade { from {opacity: 0;} to {opacity: 1;} } @-moz-keyframes fade { from {opacity: 0;} to {opacity: 1;} } @-ms-keyframes fade { from {opacity: 0;} to {opacity: 1;} } @-o-keyframes fade { from {opacity: 0;} to {opacity: 1;} } @keyframes fade { from {opacity: 0;} to {opacity: 1;} } </style> </head> <body> <div class= "about"> <h1>Who we are?</h1> <div class= "about-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan. Pellentesque commodo, enim nec faucibus tristique, risus nibh ullamcorper velit, sed egestas urna erat sit amet justo.</div> </div> <div class= "characteristics-wrapper"> <div class= "characteristics-quote"> <h1>Main characteristics of our services</h1> </div> <div class= "characteristics-container"> <div class= "characteristics-item-row1"> <div class= "characteristics-item"> <div class= "characteristics-icon"><i class="fa fa-pagelines" aria-hidden="true"></i></div> <div class= "characteristics-title">Innovative</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> <div class= "characteristics-item"> <div class= "characteristics-icon"><i class="fa fa-cogs" aria-hidden="true"></i></div> <div class= "characteristics-title">Great Features</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> <div class= "characteristics-item"> <div class= "characteristics-icon"><i class="fa fa-modx" aria-hidden="true"></i></div> <div class= "characteristics-title">Unique Design</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> <div class= "characteristics-item"> <div class= "characteristics-icon"><i class="fa fa-graduation-cap" aria-hidden="true"></i></div> <div class= "characteristics-title">Well Documented</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> </div> <div class= "characteristics-item-row2"> <div class= "characteristics-item"> <div class= "characteristics-icon"><i class="fa fa-pagelines" aria-hidden="true"></i></div> <div class= "characteristics-title">Innovative</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> <div class= "characteristics-item"> <div class= "characteristics-icon"><i class="fa fa-cogs" aria-hidden="true"></i></div> <div class= "characteristics-title">Great Features</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> <div class= "characteristics-item item2"> <div class= "characteristics-icon"><i class="fa fa-modx" aria-hidden="true"></i></div> <div class= "characteristics-title">Unique Design</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> <div class= "characteristics-item"> <div class= "characteristics-icon"><i class="fa fa-graduation-cap" aria-hidden="true"></i></div> <div class= "characteristics-title">Well Documented</div> <div class= "characteristics-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam accumsan sed leo eget malesuada. Integer dapibus nisi id eros scelerisque accumsan.</div> </div> </div> </div> </div> <div style= "height: 700px"></div> </body> </html>
  9. Hi, I want to change the background image automatically every 5 second and the indicators should be green. I followed w3schools slideshow tutorial and created this slideshow. But it doesn't seem to work as expectation. Please tell me where I made the mistake. thank you in advance. <!DOCTYPE html> <html> <head> <style> body { margin: 0; padding: 0; } .header-slideshow-container { width: 100%; margin: 0; padding: 0; } .header-slide { display: block; width: 100%; height: 100%; margin: 0; padding: 0; } #header-slide1 { background-image: url("http://www.w3schools.com/howto/img_nature_wide.jpg"); background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; } #header-slide2 { background-image: url("http://www.w3schools.com/howto/img_fjords_wide.jpg"); background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; } #header-slide3 { background-image: url("http://www.w3schools.com/howto/img_mountains_wide.jpg"); background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; } .current-header-slides-container { position: absolute; top: 45%; right: 25px; margin-top: -30px; } .current-header-slide-indicator { width: 15px; height: 15px; border-radius: 50%; margin-bottom: 5px; background-color: black; } </style> </head> <body> <div class= "header-slideshow-container"> <div class= "header-slide" id= "header-slide1"></div> <div class= "header-slide" id= "header-slide2"></div> <div class= "header-slide" id= "header-slide3"></div> <div class= "current-header-slides-container"> <div class= "current-header-slide-indicator"></div> <div class= "current-header-slide-indicator"></div> <div class= "current-header-slide-indicator"></div> </div> </div> <script> var h = window.innerHeight; (function () { 'use strict'; document.getElementsByClassName("header-slideshow-container")[0].style.height = h + 'px'; }()); var headerSlideIndex = 0; headerSlideshow(); function headerSlideshow() { 'use strict'; var i, headerSlides = document.getElementsByClassName("header-slide"), dots = document.getElementsByClassName("current-header-slide-indicator"); for (i = 0; i < headerSlides.length; i++) { headerSlides[i].style.display = "none"; } headerSlideIndex++; if (headerSlideIndex >= headerSlides.length) { headerSlideIndex = 1; } for (i = 0; i < dots.length; i++) { dots[i].style.backgroundColor = "black"; } headerSlides[i-1].style.display = "block"; dots[i-1].style.backgroundColor = "green"; setTimeout(headerSlideshow, 5000); } </script> </body> </html>
  10. Hi,I am developing my first website template. When I used this script in the internal script, it ran well. But when I added this script inside a file,the jsLint showed that there was almost 20 errors. Here I am sending the screen of the errors. Can you please help me to understand why these errors occurred and how can I resolve these? Here is the script: function openModalSearch() { 'use strict'; var modalSearch = document.getElementById("modal-search-container"); modalSearch.style.height = "100%"; } function closeModalSearch() { 'use strict'; document.getElementById("modal-search-container").style.height = "0%"; } function hideSearch() { 'use strict'; document.getElementById("search-container").style.visibility = "hidden"; } function showSearch(){ 'use strict' document.getElementById("search-container").style.visibility = "visible"; } Thank you in advance......
  11. JavaScript Function & Parameters

    var xmlhttp; var Staff, obj; var url = "staff.json"; function init() { xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ; xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { Staff = JSON.parse(this.responseText); var table = document.createElement("table"); document.body.appendChild(table); obj = Staff.Staff[0]; for (var y in obj) { var header_row = document.createElement("th"); var column = document.createElement("td"); var data = document.createTextNode(y); column.appendChild(data); header_row.appendChild(column); table.appendChild(header_row); } for(var x=0; x<Staff.Staff.length; x++) { obj = Staff.Staff[x]; if (x%2 == 0) { var row = document.createElement("tr"); row.setAttribute("class","even"); // function? for (var y in obj) { var column = document.createElement("td"); var data = document.createTextNode(obj[y]); column.appendChild(data); row.appendChild(column); table.appendChild(row); } } else { var row = document.createElement("tr"); // function? for (var y in obj) { var column = document.createElement("td"); var data = document.createTextNode(obj[y]); column.appendChild(data); row.appendChild(column); table.appendChild(row); } } } } }; xmlhttp.open("GET",url,true); xmlhttp.send(); } window.onload = init; Since the codes below "// function?" are repeated (either the row to be created in the JavaScript is odd or even), how can I write the same codes into ONE function to be shared and used in different places? Thanks for any help!
  12. Hi, I am facing problem to undestand the showSlides() function . Can you please explain this function to me . var slideIndex = 1; showSlides(slideIndex); function plusSlides(n) { showSlides(slideIndex += n); } function currentSlide(n) { showSlides(slideIndex = n); } function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); if (n > slides.length) {slideIndex = 1} if (n < 1) {slideIndex = slides.length} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; }
  13. Hello, I found a function called fnGetSibling on https://msdn.microsoft.com/en-us/library/ms533043(v=vs.85).aspx#navigate and I was hoping to understand what it does return and why. var oPrevious = fnGetSibling(); function fnGetSibling(){ var oParent=oNode.parentElement; var iLength=oParent.children.length; for(var i=0;i < iLength;i++){ if(oParent.children[i]==oNode){ return oParent.children[i - 1]; break; } } } I have three possible options: 1. Finds and returns a reference to all childs of a node of DOM Tree. 2. Finds and returns a reference to one of the children of a node of DOM Tree. 3. Finds and returns a reference to a father of a node of DOM Tree. You are not solving any homework (it's summer), it's just from a quiz.
  14. Hello everybody, I've got a little problem that I cannot get working. Hope you experts here could help me out with this. I found this hamburger menu animation by Jonsuh: https://jonsuh.com/hamburgers That thing is really nice. Now I want to trigger the animation on hover instead of click. I'd like to hover another item (e.g. 'code') and trigger the animation. Hovering 'code' would start animation and leaving the item would transform hamburger back. I tried it with the mouseover/mouseout function.... but don't know how to get this working with hamburger. I'd really appreciate every help and info. Thanks in advance!
  15. "Require_once" produces "undefined variable"

    Hi guys! I have a little problem and it's that I get an error in a determined function where I call my connection and I don't know why. The errors are: 1) Notice: Undefined variable: conexionidiomas in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 10 2) Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 11 This is what I have from "/Connections/conexionidiomas.php": # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_conexionidiomas = "p:localhost:3307"; $database_conexionidiomas = "idiomasbd"; $username_conexionidiomas = "root"; $password_conexionidiomas = "asdasdf"; $conexionidiomas = mysqli_connect($hostname_conexionidiomas, $username_conexionidiomas, $password_conexionidiomas, $database_conexionidiomas); and this in "preguntas-frecuentes.php": <?php require_once('Connections/conexionidiomas.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexionidiomas, $theValue) : mysqli_escape_string($conexionidiomas,$theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO tblfrecuentes (strPregunta,fchFecha) VALUES (%s,NOW())",GetSQLValueString($_POST['strPregunta'], "text")); $Result1 = mysqli_query($conexionidiomas,$insertSQL) or die(mysqli_error($conexionidiomas)); } ?> So, if someone could help me I'd appreciate it so much. Regards!
  16. Hello & Thanks , I am learning from this example : http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_ev_onclick I want to put the .js in a separate file , <script src="skel-main-2.js"></script> instead of within the .html . Code is here : quick.js: www.liesandcowpies.com/testMe/Quickjs/quick.js (if needed) html: http://pastebin.com/EQUTDd4y js: pastebin.com/HXbrb86M I want to put the .js in a separate file , <script src="skel-main-2.js"></script> instead of within the .html . But when I run it , up comes this console error : Uncaught ReferenceError: myFunction is not defined ? How can I connect .html with .js ? Thanks
  17. Down here the code to call a function it works with list. I dont understand how list works, In my example list gives a survey of 2 arrays that are executed inside the function here is how I call the function: $row = list ($variable, $number) = my_function(); var_dump($row); the output is like this: I need the values separated but how can I list the second array (the one with the numbers) as single numbers outside an own function?
  18. Hello, while reading the tutorial about js i found this paragraph: According to Stack Overflow fullName is not a function, because the result depends on the state of the object and is not always the same. Maybe you need to correct this or be more precise with your definition of a function.
  19. Notice Error

    Dear all: I have the following php line of code: <?php $var2 = 5; ?> += : <?php $var2 += 4; echo var2; ?><br /> Because of the lack of the dollar sign before var2 following the echo, it spat out the following error: += : Notice: Use of undefined constant var2 - assumed 'var2' in C:xampphtdocsTutorialsPHPw3schoolsintegers.php on line 29var2 My understanding prior to this was that Notice means something bad in the code but it is not an error and would not stop the code from executing. But the code has not executed in this example. Since the code is not executing, I am not seeing the real difference between Notice and other forms of errors that prevent codes from executing. Any clarification please?
  20. I need make a calculation which allow know difference between two numbers. I can subtract the smallest of the larger, but this calculation is very limited, implies if a number is negative and the other positive. I want to know another way to do this. It is possible to do this calculation in JavaScript through the: modulo; function; (Others); Mainly: Another important thing which I want, is to calculate percentage difference through two differents numbers. To know the value resultant. I want to know all the possible ways to do this. Because I came across in an embarrassing situation in a video Software that uses expressions based on the JavaScript language. Thanks!
  21. I want to add elements by the browser into an array with the name $map I wrote the next piece of code for this: <?php $var = $_POST["var"]; function addIntoArray($var) { global $map; if (($var != ".") || ($var != "..")) { array_push($map, $var); echo $var . " succesfully added to the array!"; } return; } ?> The problem though, is not having an error code, but the screen just does not give an output at all while I did make an echo line. Whats going wrong here?
  22. loop in function that shouldn't loop

    So I have this function that firsts asks the player, which player they are, then asks them a question. if they get it right their score increases by one, and an alert pops up that says correct. The problem is, after you answer a question, an alert pops up that says correct, and then another question pops up. No matter what your answer is nothing happens afterwards. Basically after everything happens, another question comes up but it shouldn't. Can anyone tell me if there is anything wrong with my code that might make this happen? function question(question, answer) { this.question = question; this.answer = answer;}var a = new question("What letter comes after 'a'?", "b")var b = new question("What letter comes after 'b'?", "c")var allquestions = [a, b];var player1total = 0;var player2total = 0;var player3total = 0; function ask(){ var num = Math.floor(Math.random() * allquestions.length); var questions_obj = allquestions[num]; var player = prompt("What player are you?" + " (Hint: use your player number not your name.)"); if (player = "1"){ var trivia = prompt(questions_obj.question); if (trivia === questions_obj.answer){ player1total = player1total + 1; document.getElementById("player1score").innerHTML = player1total; var correct = alert("That is correct!"); $("#character1").animate({top: "-=100px"}, 500); } else{ var incorrect = alert("That is incorrect!"); } } if (player = "2"){ var trivia = prompt(questions_obj.question); if (trivia == questions_obj.answer){ player2total = player2total + 1; document.getElementById("player2score").innerHTML = player2total; var correct = alert("That is correct!"); } else{ var incorrect = alert("That is incorrect!"); } } if (player = "3"){ var trivia = prompt(questions_obj.question); if (trivia == questions_obj.answer){ player3total = player3total + 1; document.getElementById("player3score").innerHTML = player3total; var correct = alert("That is correct!"); } else{ var incorrect = alert("That is incorrect!"); } }}
  23. swift mailer not sending the mails

    $email = $_POST['email'];require_once "/var/www/html/swift_mailer/swift_required.php";// Create the Transport$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com',***,'ssl')->setUsername('*******@****.com')->setPassword('***');// Create the Mailer using your created Transport$mailer = Swift_Mailer::newInstance($transport);// Create a message$message = Swift_Message::newInstance('Test Swift Mail Setup')->setFrom(array('******@***.com' => 'Statreferral Admin'))->setTo($email)->setBody($content,'text/html');// Send the message$result = $mailer->send($message); What is the wrong in this code pplease suggest me...... how can i check whether username contain mail server or not.....
  24. Random word in prompt

    Hey, so I have another question about how to write a function. What I have is a prompt, that asks, what does "..." mean? What I want is a function that randomly chooses a word from a dictionary to enter in the quotation marks. Here is my dictionary: var translation = {};// Spanish dictionarytranslation.spanish = {};translation.spanish["gato"] = "cat";translation.spanish["perro"] = "dog";translation.spanish["hola"] = "hello";// English dictionarytranslation.english = {};translation.english["cat"] = "gato";translation.english["dog"] = "perro";translation.english["hello"] = "hola"; There are two buttons. When I press the spanish button I want a spanish word to go in the quotes, and I would respond with the word translated in english. When I press the english button I want an english word to go in the quotes, and I would respond with the word translated in spanish. I would use this to review spanish vocab. How would I make a function that randomly chooses a word to go in the quotes. I know I would have to use math.random, but otherewise I do not know how to set it up. Please provide suggestions and ideas, thanks!
  25. Problem executing function

    Hello everyone, I'm having a problem executing a function, I have now tried different methods for hours and can't understand anything anymore. Now when I execute the fuction infoApp(); in this function below, then it works. function editCat(ids){ $('.mode').hide(); $('.editmode_'+ids).show(); $('.save_category_'+ids).click(function(){ var getThisName = $('.category_'+ids).val(); infoApp('cat_edit',getThisName); }); } But when I try to execute the funtion automaticly then it does not work.Like this: var getThisName = 'test value';infoApp('cat_edit',getThisName); Here's the function function infoApp(app,usedata){ $('.infomsg').show(); if(app == "cat_edit"){ $('.infomsg').text("Information, "+ usedata +" category was saved"); } $('.infomsg').fadeOut(3600); } Hope anyone got some advice for me.Kris
×