JavaScript - jQuery - Ajax

  1. » JanMolendijk
    Pleasant Coursesweb,

    The local storage for speech is limited to round 30 words.
    But may also be limited to a number of characters ?

    When I...
    Last post » JanMolendijk
    Marplo thanks for the suport.... Strange in Edge browser
    the speech is unlimited but Chrome has big limits in speech.

  2. » JanMolendijk
    On eatch minute from the current hour I wanna have an message
    I can not find out how to complete

    I hope to get something like this (code...
    Last post » MarPlo
    If you only want to display a message to every minute, just use the setInterval() function. It calls a function repeatedly, over and over again, at...

  3. » JanMolendijk
    Dear Coursesweb I can not find out how to add the hours + minutes togheter.

    <SCRIPT LANGUAGE= JavaScript >
    day = new Date()
    hr =...
    Last post » MarPlo
    See and use the following example:

    var day = new Date();
    let hr = day.getHours();
    let mn = day.getMinutes();
    let se =...

  4. » MarPlo
    I have an array of integers:
    var array = ;
    Is there a simple way to remove a specific element from an array? The equivalent of something like:...
    Last post » drakebohan
    You can use the arrayObject.filter() method :

    Example, remove 1 specific item:

    var rValue = 'three'...

  5. » JanMolendijk
    Plessant Coursesweb,
    meight useless to ask but it seems this upload for picture-album is not working on my mobile-page
    but on my computer I just...
    Last post » MarPlo
    Try to search on the internet for:
    html multiple select upload mobile

  6. » JanMolendijk
    Plessant Coursesweb, I have here an little script
    what shows directly in a document from a base-url.

    Now I would like to ad manual position...
    Last post » JanMolendijk
    Marplo Thanks alot, I just did not knewn what to do....

    Other question how is your partner
    from Coursesweb doing ?
    I think I did not see him for...

  7. » JanMolendijk
    Plessant coursesweb,

    I have a javascript what turns color-codes into color-names.
    The problem is I have 20 results from color-codes, and I can...
    Last post » MarPlo
    Try use the following code:

    const clr_codes = ;

    var clr_rgb_name =[];

    for(var i=0; i<clr_codes.length; i++){...

  8. » Marius
    I'm trying to create a script for a web page that has an audio like this:

    <div class='class1' id='id1'>
    <audio src='link_to_audio'...
    Last post » MarPlo
    Since the audio tag is a child of #id1 you can use document.querySelector() .

    To set the volume to 50%, simply use audioElem.volume = 0.5;...

  9. » Marius
    I am trying to parse a JSON string 'Hello test' containing double quote which already escaped.

    JSON.parse('{ x : Hello \ test }')

    But I get...
    Last post » MarPlo
    You just need to escape the backslash \, so it turns into two backslashes \\

    let obj = JSON.parse('{ x : Hello \\ test }')

  10. » Marius
    I have converted a database table into a JSON object.
    This is in essence a two-dimensional array, with each record being the first dimension, which...
    Last post » MarPlo
    You can use Object.keys to get the list of keys in the Object as an array and then get the length from it:


  11. » Marius
    Quick question:
    How can I set a button that can increment and/or decrement at random a number as it is clicked?
    This is the code i have....
    Last post » MarPlo
    You can use Math.random() to decide whether you are going to increment or not:

    <button id='tst_btn'>Change counter</button>

  12. » Marius
    I'm trying to convert 8-bit integer to Hex color value. (e.g. FFFFFF)
    The 8-bit color integer is generated with the following formula:

    color =...
    Last post » MarPlo
    If you have an integer you can do with:


    And it will turn it in to a hex string.

    // White
    color = (255 * 65536) + (255 *...

  13. » Marius
    In my application, I have a lot of utility functions that do little things from parsing strings to making toasts and so on.
    My question is how do I...
    Last post » MarPlo
    You can use Mixins.
    1. Import the component which you need.
    2. add mixin array as below in your component just above the data section (or...

  14. » Marius
    I have the following problem to solve it in JavaScript:
    - Find the text which is between small brackets and shift that text with the brackets to...
    Last post » MarPlo
    Try the following code:

    function testToEnd(str){
    //get matched string
    let st = str.match(/ *\( +\) */g)
    st = st ;

    // replace the...

  15. » Marius
    I am creating a website with HTML and JavaScript that relies on the data of an XML file hosted on a separate domain.
    I can achieve this with...
    Last post » MarPlo
    Try using the the fetch api.

    .then( response => response.text() )
    .then( response => {
    //response is...

  16. » Marius
    I have a for() loop like this one which shows what i want to do.

    for(var i=0; i<15; i++) {
    // Add data in html
    // When data has a specified...
    Last post » MarPlo
    To achieve your goal you can add the if() condition within the loop, and check the values of your data.
    If it has the specified value, sets the new...

  17. » Marius
    With the good old for loop in Javascript I can do things like:

    for (let i=0; i<bla.length; i+=2){

    So for every count, I can skip...
    Last post » MarPlo
    You may add an if() statement within the for...of loop, like in the following example (the original index is preserved).

    for (const of...

  18. » Marius
    How can I make that when an option from dropdowna <select> list is selected, the value of that option be displayed into a Div.
    I have this...
    Last post » MarPlo
    You have to start with a <select> element which raises a 'change' event when an option is selected.
    Inside that event, 'this.value' refers to...

  19. » Marius
    Say I have the following array of persons:

    const arr =

    And I want to find a certain person (name) in this array, and put it as the first...
    Last post » Admin
    You could sort the array with the sort() method.
    This approach moves all objects with the wanted 'name' to top.

    const arr = ;
    let first =...

  20. » Marius
    I have a nested object in JavaScript that looks like this:

    const yo = {
    one: {
    value: 0,
    mission: 17},
    two: {
    value: 18,
    mission: 3},...
    Last post » Admin
    Try combine the Object.values() and map() methods, like in the following example:

    const yo = {
    one: {
    value: 9,
    mission: 17
    two: {...

  21. » Marius
    I’m trying to replace all spaces within a string with hyphens.
    I tried this:

    let str ='This is my text';
    str = str.replace(/\s/, '-');...
    Last post » Admin
    Add the global search flag (/g ) to your regex to match all occurrences.

    let str ='This is my text';
    str = str.replace(/\s/g, '-');...

  22. » Marius
    The code below sends the 30s event do Google Analytics after 30 seconds a user enters a page.

    gtag('event', '30s');
    Last post » Admin
    You can watch for when a tab loses focus by using the event listener 'visibilitychange'. When the visibility changes, you can use 'document.hidden'...

  23. » Marius
    I have a JavaScript code that adds an input field for a user:

    var user = O'Conner, John ;
    b.innerHTML += <input type='hidden' value=' + user +...
    Last post » Admin
    You can replace the character with its HTML entity.

    As for ' - It can either be &rsquo; or &lsquo;

    var user = O'Conner, John ;
    user =...

  24. » Marius
    The idea is that when i click on a button, old content gets replaced by new HTML content added with javascript.
    I want that new content to appear...
    Last post » Admin
    To trigger a CSS transition, change the CSS state after you inserted the HTML. You can do this by changing a class (on the container or an inserted...

  25. » Marius
    I want to create a toggle function for my localStorage where I want it to remember the user's choice.
    I want it load the current preference on page...
    Last post » Admin
    You can't keep boolean in localStorage. That's why you have an error. Try to keep, for example, 0 for False and 1 for True. But remember that...