Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. You can also use jQueryUi autocomplete for that,you can find all the references here:https://jqueryui.com/autocomplete/
  3. You have not declare I with datatype of int ,var then you facing error in for loop
  4. Yesterday
  5. You cannot pass values to addEventListener callbacks. Callbacks have to be just the name of the function without parentheses. If you use parenthesis, you will call the function immediately and assign its return value as an event listener instead.
  6. Hello, I'm having issues trying to set up custom input number arrows, I'm currently learning JavaScript so I'm not really sure what I'm missing, here is my code. HTML <div class="orden"> <label for="pase por dia">Boletos deseados: </label> <div class="caja_ticket"> <input type="number" min="0" id="test" size="3" placeholder="0" class="ticket"> <div class="botones_ticket"> <input type="button" id="pase_dia_mas" value="+"> <input type="button" id="pase_dia_menos" value="-"> </div> </div> </div> JavaScript I have 3 input with the id = test so to save some code I decided to use a querySelectorAll('#test') to get an array of them, and then when I click the button I want to call the function "mas1" var test = document.querySelectorAll('#test'); var paseDiaMas = document.querySelector('#pase_dia_mas'); paseDiaMas.addEventListener('click', mas1(event, 0)); function mas1(event, e) { event.preventDefault(); let test_value = e; test[test_value].stepUp(1); console.log('it works'); } however when I try to pass the values it doesn't works, if I remove the variables "test_value" and "e" and add a fixed value like "test[0]" it works: I also wonder why when I remove the event.preventDefault() function it runs once when I open the page even if I don't click at the button.
  7. Ingolme

    It is SCSS, not SASS

    Are you referring to the SASS tutorial? https://www.w3schools.com/sass/default.asp SASS is a CSS preprocessor: https://sass-lang.com/
  8. It is probably faster to reach them by email. I am not sure how frequently they look at the forums. At the bottom of each page is a button labeled "Report error". If you click on it it displays the email address (help@w3schools.com) to which you can indicate a mistake on any page.
  9. Does anyone know how to format paragraphs in XML?
  10. Hello, looks like there's a minor error in the example code given for the index.html page for the "Node.js and Raspberry Pi - Webserver with WebSocket" page (which I'm very grateful was provided, btw). Half way through the article, there's an index.html example that has an extra html opening tag, and extra close body and html tags. It's not an issue for people who realize the issue, but figured the page could use a quick update if possible. Thank you for all the great content! Ref: https://www.w3schools.com/nodejs/nodejs_raspberrypi_webserver_websocket.asp <!DOCTYPE html> <html> <body> <h1>Control LED light</h1> <p><input type="checkbox" id="light"></p> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script> <!-- include socket.io client side script --> <script> var socket = io(); //load socket.io-client and connect to the host that serves the page window.addEventListener("load", function(){ //when page loads var lightbox = document.getElementById("light"); lightbox.addEventListener("change", function() { //add event listener for when checkbox changes socket.emit("light", Number(this.checked)); //send button status to server (as 1 or 0) }); }); socket.on('light', function (data) { //get button status from client document.getElementById("light").checked = data; //change checkbox according to push button on Raspberry Pi socket.emit("light", data); //send push button status to back to server }); </script> </html> </body> </html>
  11. I think I've finished my first web but I don't know how to make links from nav menu work and i don't know how to make links from my footer work. Can someone tell me what i'm doing wrong or where can I read the solution. Thanks. Curriculum Víctor.zip
  12. Is anybody aware of that the tutorial of SASS is actually SCSS? Syntax @import and @include and so on are all SCSS. The whole tutorial is about SCSS syntax but the whole titles are all SASS.
  13. Last week
  14. Here's something you might be able to modify to your specific needs: <!DOCTYPE html><html lang="en"><head><title> Ian's Converter </title> <meta charset="UTF-8"> <meta name="viewport" content="width-device-width,initial-scale=1.0, user-scalable=yes"/> <!-- From: https://w3schools.invisionzone.com/topic/61432-quantity-converter-problem/ --> <style> .container { display: grid; grid-template-columns: auto auto; padding: 10px; width: 30em; } .item { border: 1px solid rgba(0, 0, 0, 0.8); } body { background-color: lightBlue; } h1 { font-size: 50px; text-align: center; } h2 { font-size: 30px; } fieldset { width: 30em; } #calculate { font-size: 25px; } button, label { cursor: pointer; } textarea { height: 10em; width: 40em; } </head><body> </style> <h1> Ian's Quantity Converter </h1> <h2> People to Serve </h2> <div class="container"> <div class="item"> <div><input id="orginal" value="2" size="4" placeholder="Ingredient"> <label for="original"> Orginal No. of People </label></div> </div> <div class="item"> <div><input id="current" value="4" size="4"> <label for="current"> Current No. of People </label></div> </div> </div> <br> <fieldset><legend> Ingredients and Quantity </legend> <div id="stuff" class="container"> <input class="item" value="" value="" size="30" placeholder="Ingredient"> <input class="item" value="" value="" size="5" placeholder="Quantity"> </div> <p> <button id="addStuff"> Add Stuff </button> </fieldset> <p> <button id="calculate"> Calculate Amounts </button> <h2> Results </h2> <textarea id="results" readonly></textarea> <script> (function (d) { console.clear(); function calculateResult() { d.getElementById('results').value = `${'Ingredients'.padEnd(40,' ')} : Quantity\n`; var sel = d.querySelectorAll('#stuff input'), serving, actualServing; for (let i=0; i<sel.length; i=i+2) { serving = sel[i+1].value / orginal.value actualServing = serving * current.value d.getElementById('results').value += `${sel[i].value.padEnd(40,' ')} : ${actualServing}\n`; } } function addElement(tagName, elClass='', idName='', info='', parent=document.body) { var tag = d.createElement(tagName); var txt = d.createTextNode(info); tag.appendChild(txt); if (idName != '') { tag.setAttribute('id', idName); } if (elClass != '') { tag.setAttribute('class', elClass); } parent.appendChild(tag); return tag; } /* addInput( tagType='text|button|checkbox|radio', idName='|ID|name', info='', parent=document.body action=null|function ) */ function addInput(tagType='text', elClass='', idName='', info='', parent=document.body, action=null) { var tag = d.createElement('input'); tag.setAttribute('type', tagType); if (tagType == 'radio') { tag.setAttribute("name", idName); } else { tag.setAttribute("id", idName); } tag.setAttribute('placeholder', info); tag.setAttribute('value', ''); if (elClass != '') { tag.setAttribute('class', elClass); } if (typeof action == 'function') tag.addEventListener('click', action); // element function when clicked parent.appendChild(tag); return tag; } function btnClear(el) { while (el.firstChild) el.removeChild(el.firstChild); } var addStuff = function() { // tag, class,id,info,parent [,action] addInput('input','item','','Ingredient',d.getElementById('stuff')); addInput('input','item','','Quantity',d.getElementById('stuff')); } d.getElementById('addStuff').addEventListener('click', addStuff); d.getElementById('calculate').addEventListener('click', calculateResult); })(document) </script> </body></html> Possible modifications if desired: 1. Remove line of "Ingredients | Quantity" if added in error or just clear contents of last entry 2. Skip "Results" display line if "Ingredient" is blank 3. Change "Results" display to a <OL> list display 4. Alter "Quantity" values to limit to 2 or less decimals if math converts to weird fraction. Good Luck! BTW, welcome to the forums.
  15. In UTF-8 encoding, any Unicode character with a code higher than 127 is split into multiple bytes. Each byte starts off with a number of 1s indicating how many of the following bytes belong to the same character. UTF-8 encoded bytes have structures like the following: 0XXXXXXX 110XXXXX 10XXXXXX 1110XXXX 110XXXXX 10XXXXXX Your character has to be split into two bytes because its Unicode value is highter than 127. Its binary representation is: 10111101. These bits are split into the following two UTF-8 bytes: 11000010 10111101. The hexadecimal representation of the above bytes is C2 BD If you're actually seeing the C2 character, it means that the the software reading the bytes is not aware that it is UTF-8 encoded. The email has to contain a header indicating that it is using UTF-8 as the character encoding.
  16. OK. I can accept that answer. However, I am having the data sent to me via email, and when I look at it in my text editor the %C2 character is different from any character I am using. Why does the %C2 portion of the field get encoded to %C2 and not %00?
  17. I think it looks correct. It is passing a two-byte UTF-8 encoded character. The %## encoding in a URL can only have two characters following the %. If you have a multi-byte character, each byte will be encoded on its own. The server should be able to decode it without a problem as long as it is treating strings as UTF-8.
  18. It has an error because you forgot to declare i with the var keyword.
  19. I have a form that I use to send me data that includes the &frac12; value. Instead of %00BD, I am getting %C2%BD. Can anyone tell me how to correct this, or if it's even correctable? Wayne
  20. Hello, to my experience the following does not work (tryit-editor w3School), but it does with a "while" loop instead. Are "for" loops not allowed within classes? <p id="demo">result</p> class Test{ counter(){ var result=0; for(i=0;i<10;i++){ result++; } return result; } counter2(){ var result=0; while(result<10){ result++; } return result; } } var obj=new Test(); document.getElementById("demo").innerHTML=obj.counter(); //document.getElementById("demo").innerHTML=obj.counter2();
  21. I think it's because you aren't very good at English yet. Honestly I'm learning HTML on this website and so far its doing a very good job, I'm having no problems. I did have a problem on the part where you learn about image maps, it didn't really explain it very well how to do it, so I watched a youtube video on image maps and I instantly understood how, honestly if there is something you dont understand go and watch a youtube video on it. I think its just your level of knowledge of English is really bad. Reading your post I cant really even understand what your are trying to say thats how bad your English is, sorry bro.
  22. ShadowMage

    Non-numeric Value

    Ok, so this is stemming from the fact that I can't get any output from PHP except errors when they occur (as described here) but since that doesn't seem to be an issue that's going to be resolved any time soon, I need to figure out how to work around it. So, I split this issue (which I also posted in the linked thread) off into it's own separate thread to see if I can resolve this particular issue. Anyway, I'm getting this error: PHP Warning: A non-numeric value encountered in ...filepath... on line 166 Line 166 looks like this: $numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty']; The error doesn't even tell me which of the three variables is throwing the error. Normally, this wouldn't be an issue, because I'd just print out all the variables in the equation to see what they're being set to. However, due to the previously mentioned issue, that's not possible. So, I've tried to catch this error in the following ways: try { $numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty']; } catch (Throwable $e) { echo "<pre>".print_r($Dim, true)."</pre>"; } and: $blnDump = false; $which = ''; if (!is_numeric($Dim['bays'])) { $blnDump = true; $which = 'bays'; } elseif (!is_numeric($Dim['purlins'])) { $blnDump = true; $which = 'purlins'; } elseif (!is_numeric($Dim['qty'])) { $blnDump = true; $which = 'qty'; } if ($blnDump) echo "$which was non-numeric:<br /><pre>".print_r($Dim, true)."</pre>"; but neither one catches the error and I just get the error printed on the page. The error prints twice, because the code above is in a function that gets called multiple times within a loop, and the issue apparently is occurring on two different iterations of the loop. And, because the code is in a loop, I can't use exit; or die(); to kill the script and print my debugging messages, because it kills the script on the first iteration of the loop. As luck would have it, the first iteration is error free and is therefore unhelpful to say the least. Please help?
  23. This is really beginning to be a problem... I've found all the division by 0 errors I had before, but I still have this guy: PHP Warning: A non-numeric value encountered in ...filepath... on line 166 Line 166 looks like this: $numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty']; The error doesn't even tell me which of the three variables is throwing the error. Normally, this wouldn't be an issue, because I'd just print out all the variables in the equation to see what they're being set to. However, because of the issue that started this thread, that's not possible. I've tried to catch this error in the following ways: try { $numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty']; } catch (Throwable $e) { echo "<pre>".print_r($Dim, true)."</pre>"; } and: $blnDump = false; $which = ''; if (!is_numeric($Dim['bays'])) { $blnDump = true; $which = 'bays'; } elseif (!is_numeric($Dim['purlins'])) { $blnDump = true; $which = 'purlins'; } elseif (!is_numeric($Dim['qty'])) { $blnDump = true; $which = 'qty'; } if ($blnDump) echo "$which was non-numeric:<br /><pre>".print_r($Dim, true)."</pre>"; but neither one catches the error and I just get the error printed on the page. The error prints twice, because the code above is in a function that gets called multiple times within a loop, and the issue apparently is occurring on two different iterations of the loop. And, because the code is in a loop, I can't use exit; or die(); to kill the script and print my debugging messages, because it kills the script on the first iteration of the loop. As luck would have it, the first iteration is error free and is therefore unhelpful to say the least.
  24. web page auto scroll up when ticker working,how to prevent that auto scroll up? just see the video from here for understand the issue https://youtu.be/w0Ok9rb3Mrg
  25. So, I'm bumping this back up because it's become an issue again. I had been working around it using die() to print out variables and such just before any offending lines, but I've encountered a situation now where that doesn't work. Consider the following: $x = 10; $y = 3; for ($z=0; $z<10; $z++) { echo "Attempt $x / $y: "; echo ($x/$y)."<br />"; $y--; } In PHP 5, I would get output as: Attempt 10 / 3: 3.33333333 Attempt 10 / 2: 5 Attempt 10 / 1: 10 Attempt 10 / 0: PHP Warning: Division by zero in C:\inetpub\major\test.php on line 37 Now, in PHP 7, I just get the error. And I can't use die() in the loop to print the "attempt..." line because the first iteration through the loop is correct and functional. I really need to figure out how to make PHP output everything again like it used to. While writing this, I thought of a workaround for the above situation. I could put a conditional to check the value of $y like this: $x = 10; $y = 3; for ($z=0; $z<10; $z++) { if ($y==0) echo "dividing by 0: $x / $y<br />"; echo "Attempt $x / $y: "; echo ($x/$y)."<br />"; $y--; } Or use a try/catch block for more complicated equations. Maybe this is best practice anyway? EDIT: Turns out a try/catch doesn't catch this error apparently... I don't know. Still seems silly to me that PHP would prevent all other output in the event of a non-fatal error.
  26. This pattern should work: ([0-9]{9})?
  27. The best way to learn is to set yourself a project and try to accomplish it. Along the way you'll run into problems you don't know how to solve. When you do, you do research on those specific things and that is how you learn. You will find tools in Java which do what you need them to. The more problems you run into while developing something, the more things you will learn when researching the solutions to those problems. On the other hand, try not to start a project that is too far out of your reach.
  1. Load more activity
×
×
  • Create New...