JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and  in almost every mainstream web browser.

Share tech news, updates, or what's on your mind.

Sign up to Post

Not sure where to begin, I am using a CSV to Html table template by Derek Eder
I'm using it to display a list of events that have happened, I would like to see if there is a way to make the default sort for the java app be reverse chronological order instead of chronological order. I know there are multiple sort functions, however since I am automatically refreshing every 10 seconds and it would be handy to have the results sorted the way I would like automatically.
I don't have any experience in java so any help would be greatly appreciated.
I want to start learning Angular JS. Looking at the tutorials there are several different ways to set up the environment, which uses gulp, bower and many more
what is the simplest way to  get started with, to start learning this framework.
Hi Experts,

I've been using a JS export code that allows me to take data that is being passed from my dashboard and exported as a new excel file (xls).  The export function allows you to save the name of the file, and sheet name.  All this is great.  What I am needing help on is how can we programmatically save the exported file to a pre determined folder (network drive)?  I am not familiar with JavaScript so any assistance would be greatly appreciated.  

This is a request that will give executives the ability to click on a report used for certifying data and have to only hit "Certify" and the csv is placed in a network drive (folder) and the executives will never have to do anything other than hit the certify button. The problem with my code now is that it saves on the local machine as a default.

I'm trying to figure out how I can scrap/detect if the phrase "We regret we cannot open the account you requested." is on the page using CSS Selector and/or Javascript (jQuery is ok if that is the only option but want to avoid it if possible?). Below is an excerpt from the mark-up.
<!-- current page: offers --> 
        <div class="main">
     <h3>Eligibility Results</h3><p>Thank you for your online application for an account at Bank of the West.  We regret we cannot open the account you requested.<br/>
If you would like to discuss this application with Bank of the West, please contact us at:</p>

Open in new window

Need to show or hide a DIV with Javascript based off of PHP string variable. Basically, I have a DIV with a lot of information and do not want to show it on the page, if the information supplier with the PHP script has not values. I am testing the value by setting a php variable and want to use javascript to see if there is a string in the php variable and if so, show the div. If the string is empty or blank, then hide the DIV.
I'm working on a web site with a search box that shows the search results in an overlay with the original page unavailable in the background. I need to change the focus to the first link in the search results box so that visually impaired people using an OCR will hear or feel the brail of the first search result. (Currently the OCR continues to read from the page behind.)
The search uses as the search engine.
After the search completes, one of the <div> tags gets an extra class: The <div> goes from :
<div class="gsc-results-wrapper-overlay" >
<div class="gsc-results-wrapper-overlay gsc-results-wrapper-visible">
That gsc-results-wrapper-visible class gets added to the div tag.
The page is created with SharePoint and so I don't want to mess with that unless there is no other choice. I want to do everything on the client side if possible.
My question is, how can I capture that div element when the search finishes. What DOM event would I react to? More generally, how can I discover these DOM events myself using developer tools?
I thought about something like this:
document.getElementsByClassName("gsc-results-wrapper-overlay").addEventListener("eventX", displayDate);
But even then I don't know what "eventX" would be.
The site is here:
I have a script that paginates pages in a table, which works fine. I also have a dropdown to select how many records to show in the table. Although this works, if I select say 20 records the pagination does not update to reflect the change.

When the table is run, the default records to show is 8 whih makes 9 pages. But if I select 20 in the drop down it still says 9 and if I go to page 9 it is obviously empty. I am also wondering if it is possible to have the script appear in both before and after the table. the reson for this is if a user gets to the bottom of say 100 records, then I would like this feature so they don't have to go all the way back to the top.

I would appreciate any help as my javascript is not 100%. Many thanks


    echo "<table class='paginated' cellspacing='0' cellpadding='0'>";
    echo "<div class='pager'></div>";
    echo "<thead><tr><th style='width: 5%;'>#</th><th>Service</th><th>Activity</th><th>Dept</th><th>Company</th><th>Address</th><th>User</th><th>Item</th><th>Date</th><th style='width: 19%;'>Action</th></tr></thead>";

    while($row = mysqli_fetch_array($result)){

    $id = $row['id'];
    $service = $row['service'];
    $activity = $row['activity'];
    $dept = $row['department'];
    $company = $row['company'];
    $address = $row['address'];
    $user = $row['user'];
    $box = $row['item'];
    $date = $row['date'];
    $date = date('d-m-Y h:i:s', strtotime($date));
    $edit = "<button type='button' class='btn

Open in new window

i have end dates that are stored in the database as: February 15, 2018 10:9:29

one is created from edge browser, one from chrome and one from FF. all of them are stored with the same string.
but all these browsers interpret the date differently. i attach the console images:
edge interpret all of them.
chrome and FF see the one that was created with edge as Invalid Date
also, FF interpret the date differently than chrome.

the aim is to delete the record if the date and time has past. so i have this:
let today = new Date();
console.log('today: ',today);
          data.forEach((data) => {

            if( new Date(data.enddate) < today  ){
              //delete automatically hangouts which are past due date
              console.log('in the past: ',new Date(data.enddate));
              console.log('not in the past: ',new Date(data.enddate));


Open in new window

the issue is that the deletion obviously does not work with the Invald date.

any idea?
from chromefrom edgefrom FF
Hi I am trying to get my games to output the current time in seconds that the game is running for as a score for the player in the canvas but I keep getting an undefined var instead of the number?

Does anyone have any idea whats wrong with my code??

Thanks, See code below.

HTML5 Canvas
var Game = {
    canvas : undefined,
    ctx : undefined,
    backgroundImage : undefined,
    backgroundMusic :undefined,
    soundImage: undefined,
    soundImagePosition : { x : 750, y : 10 },
    vy : 0,
    rocket : undefined,
    rocketPosition : { x : 350, y : 400 },
    dxSpeed: 7,
	dySpeed: 3,
	keyboard : { keyDown : -1 },
	keys : {
    A: 65,     B: 66,      C: 67,      D: 68,       E: 69,      F: 70,
    G: 71,     H: 72,      I: 73,      J: 74,       K: 75,      L: 76,
    M: 77,     N: 78,      O: 79,      P: 80,       Q: 81,      R: 82,
    S: 83,     T: 84,      U: 85,      V: 86,       W: 87,      X: 88,
    Y: 89,     Z: 90, 	   LA:37,      UA:38, 	    RA:39,      DA:40,

function handleKeyDown(evt) {
    Game.keyboard.keyDown = evt.keyCode;

function handleKeyUp(evt) {
    Game.keyboard.keyDown = -1;

Game.start = function () {
    document.onkeydown = handleKeyDown;
    document.onkeyup = handleKeyUp;

    Game.canvas = document.getElementById("myCanvas");
    Game.ctx = Game.canvas.getContext("2d");

    Game.backgroundMusic = new Audio();
    Game.backgroundMusic.src = "assets/audio/start.mp3";

Open in new window

I have a text field where users enter whole numbers.  What I want to do is to automically add a decimal point and two zeros to the end of the number (ex: 123.00) when it is manually entered.  For some reason, it is too much work for users to simply add .00 manually.
Hi Guys,
I am returning JSON data from the server with ajax. When the data return it come like:

The issue I have here is the quotation in the beginning and the end. I do I remove these quotations. I have to take this data above and make it like a string.
I was trying many things like stringify, replace.
please see my code example:

function GetData() {
        var data;
            type: "GET",
            url: '/Tables/Getpaging',
            dataType: "json",
            async: false,
            //data: {},
            success: function (resp) {
                data = resp
        return data;

    var Dataobj = GetData().BindData;

function GetHeaders() {
        var headerName = "";
        for (var i = 0; i < Dataobj.length; i++) {
            if (i == 0) {
                for (var key in Dataobj[i]) {
                    headerName += "'" + key + "',";
            } else {
        var arr = "[" + headerName + "]";
        return arr;

Open in new window


Can anyone remind me how to disable right-click using JS/jQuery?

Also, although doubtful, as I'm working with sensitive data, is it possible to disable copying, highlighting, Ctrl+C,Alt+Print Screen, and other methods of replicating the data?

Thank you..
I had this question after viewing Extracting text from a lookup field in a SharePoint 2013 workflow.

My issue is that I have three lookups.  They are creating a cascading drop down.  The problem is, to make the Cascading Drop Down work, I have to add the ID of the first list.  So even though the Display on my form does show the Titles the value that is passed is an integer.  Any thoughts on how to capture the text values rather than the underlying ID values?  I am also using an InfoPath form for my form.

-- No responses so I will clarify for simplicity.  
  - Lookup 1 (ID and Title)
  - Lookup 2 (ID, Title, Title from Lookup 1)
  - Lookup 3 (ID, Title and Title from Lookup 2)

This works find for three drop downs on my form.  The issue is when the record is saved, the value (ID Integer) of each lookup is saved rather than the DisplayName.  I'm trying to capture the DisplayName so I can pass it to another list.  I know how to pass the field values, but again, I'm not looking for the ID value, I want to DisplayName value.  I have seen it done with standard forms in SharePoint Designer using Javascript, but I am using Infopath Custom forms. You will see from the image that where EIS Part is the selector.  The field I want to fill is EIS Part A.  Instead of getting the longer text in EIS Part to display in EIS Part A, it shows the ID which is 2. Snipaste_2018-02-13_12-24-41.png

I have this page:

I use a DataTable on the page to present search results.
At the top-left of the DataTable I am showing the Info block and at the top-right the Search block.
My problem is that both blocks are mis-functioning in a strange random-like way.

The Info block counts wrong - sometimes it says 1 of 1 entries when there are 200 entries and sometime it says 12 of 12 entries when there are 47 entries. It looks a little like it is random what it says.
The searchblock is not reducing the results according to text entered in the Search field. I t also seems a little random what it actually do.

I Have DataTable working on many of my other pages without any problems, and I can't figure out what is wrong here.

I have this code in the head of my main file:
<link rel="stylesheet" href="">
    <link rel="stylesheet" href=""> 
    <link rel="stylesheet" type="text/css" href="../../templates/template_style.css"> 
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel="stylesheet" type="text/css" href="" />
    <script src=""></script>

Open in new window

In this example, they are using a JavaScript function to get the host name of the page.

Is there a way to do this exact same thing using jquery ?
I am really confused as to why my code is not working. Here is the problem and my code below.
The class Puppy needs two methods.

The getsTreat method should accept one parameter. It should increase happiness by 20 for each treat received, then return the new happiness value.

The takesNap method should decrease energy by 45 and increase behavior by 15.

Make sure you make the puppy take his nap in order to change his energy and behavior levels.
class Puppy {

  constructor(happiness, energy, behavior) {
    this.happiness = happiness = energy
    this.behavior = behavior
  // code here
    return this.happiness + num * 20;
  takesNap(){ - 45;
    this.behavior + 15;

var Charles = new Puppy(75, 25, 30)
Looking to have 100% height on two divs side by side. I want to keep each div independent in scrolling content in each but in the blue div/column, I would like to have a smooth scroll feature. It works now but you will see the red column does not retain its 100% column height.

Thanks for any insight...
Hi E's,
I try to get a solution for send via Jquery ajax a object and a variable at the same call.
This is the code I have when the data is one object:
var file_data = $('#imagem').prop('files')[0];    
                    var form_data = new FormData();                  
                    form_data.append('file', file_data);                            
                        url: 'ajax_upload.php', 
                        dataType: 'text',  
                        cache: false,
                        contentType: false,
                        processData: false,
                        data: form_data,                         
                        type: 'post',
                        success: function(php_script_response){
                            alert(php_script_response); //

Open in new window

In above code "form_data" contain the information of a upload file.
My problem is, I have a simple variable to send in the same call, and usually when I send variables I use "data" like this: data: {"var":value},.
But I don't know send both, object and variable.
I need some solution that send both things, like this: data: {"var":valor, "var":valor},+form_data;

Can you help me please?!

The best regards, JC

I need what I think is a media query that will sense when an incoming web visitor is using a cell phone or tablet -- and then will automatically redirect them to another web page in the same domain.

Hi everybody.
I have a problem with PHP sessions.
I have developed a backend for a mobile app developed by another team of devs. The app send requests to my php scripts which collects data and send them to the mobile app.
The problem is that I have used PHP sessions and this way, if the mobile app doesn't send requests for 30 minutes, the session expires and the php scripts return bad or null values.

I have now to manage this issue and I'm wondering what is the best way to do it. Can I set the php.ini in order to make sessions never expire? Or do I have to tell developers to use Ajax to prevent session expiring? Or there is some better way?

Thanks for any suggestion :)
I have a JS Code which goes to a new site upon click or/and enter. I would like to the new site to open in a new tab or window. Right now it is opening in the same window. I have tried adding" ") around my links, but that didn't work. Also use of iframes is not allowed. Your help is greatly appreciated.
<div class="product-price"><span class="price"><strike>349,00&nbsp;</strike></span>49,00&nbsp;<span class="currency">DKK</span></div>

How does I find 49,00 ?
I can´t change the DOM, so I need to find it due jQuery.
I have a folder full of images (with specific quotes in them) that I would like to randomly swap out on page load.  Not sure the best way to get this done.
Hi Guys,
I am developing application that returns table of information.
The database the company use is big. When I say big I mean 5000000 million records for a table.

After a research I found some nice js framework to use (

I return JSON data and show on the table, but the issue is when I have big data it goes out of memory.
My question is:
How do I return data efficiently with ajax call?
How do I handle this amount of return?

If you suggest it is paging, then tell me how can I do it through the UI and serverside implementation.

Thank you.
Why my form are still appear when the radio button is unchecked?amend_script.php






JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and  in almost every mainstream web browser.