JavaScript

123K

Solutions

42K

Contributors

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

I need to capture the exact time and write it to a sql server db via a classic asp web page.  I have a page that does that now...sort of.  It uses the Now() asp function.  The problem is that, if the internet happens to be slow where we are, by the time the command goes to the server, the time may not be as precise as we need.  Is there a way to capture that time client side (using javascript for instance) and then write it to the server, all with one button submit?

Thanks in advance for your help.
0
Ensure you’re charging the right price for your IT
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

What is the proper JavaScript regex to cover these hosts?
  • apply.essexcredit.com
  • apply-uat.essexcredit.com
  • apply-qa.essexcredit.com

Thanks!
0
The following code works just fine:

app.use((req, res, next) => {
  if (!req.session.user) {
    return next();
  }
  User.findById(req.session.user._id)
    .then(user => {
      if (!user) {
        return next();
      }
      req.user = user;
      next();
    })
    .catch(err => {
      throw new Error(err);
    });
});

Open in new window


 I'm just wondering what the difference is between next(); and return next();

The way that I've seen it explained on the web is that when you write "return next();" you're "...compelling your app to stop the execution of the code once the callback is completed."

The first thing that's happening is I'm looking for the presence of a session id. If one is not present, I'm thinking that "next" in this case is referring to the User.findById dynamic, yes? And because it's coded alongside "return," that definitively routes the code to the next piece.

Yes?

You wouldn't HAVE to write "return," but it's a good practice, especially in this instance correct?

But here's where I start getting a little fuzzy.

You're now in the "User.findById" piece and if you dop't find a user you get "return next();." Well, what is "next?"

I might be misinterpreting "next" to mean the next piece of the surrounding code.

Bottom line: I'm a little confused as to what "next" means and the difference between using "return next" and simply "next."

Can you help a brother out?
0
hi

how can i remove a node from html collection xml in javascript
0
error in my angular hi am geting this error
compiler.js:2175 Uncaught Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'input'. ("
           placeholder="Add New Task"
           (keyup.enter)="onTaskAdd($event)"
           [ERROR ->][(ngModel)]="addTaskValue"/>
</div>
"): ng:///AppModule/TasksAddComponent.html@5:11
    at syntaxError (compiler.js:2175)
    at TemplateParser.parse (compiler.js:11388)
    at JitCompiler._parseTemplate (compiler.js:25961)
    at JitCompiler._compileTemplate (compiler.js:25949)
    at compiler.js:25893
    at Set.forEach (<anonymous>)
    at JitCompiler._compileComponents (compiler.js:25893)
    at compiler.js:25806
    at Object.then (compiler.js:2166)
    at JitCompiler._compileModuleAndComponents (compiler.js:25805)
syntaxError @ compiler.js:2175
parse @ compiler.js:11388
_parseTemplate @ compiler.js:25961
_compileTemplate @ compiler.js:25949
(anonymous) @ compiler.js:25893
_compileComponents @ compiler.js:25893
(anonymous) @ compiler.js:25806
then @ compiler.js:2166
_compileModuleAndComponents @ compiler.js:25805
compileModuleAsync @ compiler.js:25767
compileModuleAsync @ platform-browser-dynamic.js:223
compileNgModuleFactory__PRE_R3__ @ core.js:40263
bootstrapModule @ core.js:40598
./src/main.ts @ main.ts:11
__webpack_require__ @ bootstrap:79
0 @ main.ts:12
__webpack_require__ @ bootstrap:79
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
0
Hi
I found a very promising looking javascript youtube for beginning a javascript game done in the window.requestAnimtionFrame method system , which appears to be best.

My transcribing it from video to Atom IDE loads the mutalisk I substituted for their GIF in the animation,
but it doesn't move after the requestAnimation x,y individual incrementation in my helper method movement statements.
 
I'm confident it will be obvious to a JS master on sight where my code is lacking

The Youtube that moves a GIF is here

I was pleased my code appeared to be promising, but the moving of said mutalisk doesn't happen

MY CODE ATTEMPT IS HERE:

<!DOCTYPE html>
<html>

<head>
  <title> Title something something</title>
  <style type = "text/css">
    body {
      background-color: #FFF;
      margin: 30px;
      margin-top: 10px;

    }

    #contentContainer {

      width: 550px;
      height: 350px;
      border: 5px black solid;
      overflow: hidden;
      background-color: FFFF00
    }

    #thing {
      position: relative;
      left: :25px
      top: 50px
    }
    </style>
  </head>

  <body>
    <div id = "contentContainer">
      <img id = "mutalisk" src = "http://jamescomp.com/pics/mutalisk.gif"
      height="75" width="75">
    </div>

  <script>
      var theMutalisk = document.querySelector("#mutalisk");
      var currentPosition = 0;

      var requestAnimationFrame = window.requestAnimationFrame 

Open in new window

0
Hi Experts,

Can you anyone see why the Currency converter stopped working for some reason at https://www.aces-project.com/index.php/live-apps/

If you place a breakpoint at line 76 on https://www.aces-project.com/wp-content/themes/aces-project/live-apps.js, then run it, you'll notice that  I set my url appropriately on  Li. 35, but within my AJAX Call neither my url is appended from Li. 44 nor any data  is sent to the php script from Li. 49-52

Any help would be greatly appreciated.
Thank you!
0
Hi Experts,

I just installed reCapcha v3 on my WP site with Contact Form 7, and it in Chrome's Console I see JS Warnings, Why is this?

Until now I had Contact  Form 7 without validation, but get spam and decidedd to install reCapcha
0
I have a ticketing system which is written in KnockOut using template. Template structure is as below This template is repeated for multiple users on a page. In this parent.AssignedTickets is a list of Ticket Id assigned to users.

<script type="text/html" id="TicketAssignmentTemplate">
    <td>
       <label data-bind="css: {success: $root.getCheckStatus(TicketId, $root.AllAssignedTickets)}">
          <input type="checkbox" data-bind="checkedValue: TicketId, checked: $parent.AssignedTickets" />
        </label>
    </td>
    <td>
        <label data-bind="text: title"></label>
    </td>

           self.getCheckStatus = function (itkID, ListID ) {
                if (ListID.indexOf(itkID)>= 0)  return true; else return false;
            }

</script>

<style>.success{background-color: #DFF0D8;}</style>

Open in new window


So system has multiple TicketIDs and if it is assigned to user by checking the check box, parent.AssignedTickets gets updated and I update root.AllAssignedTickets, both of which are observable arrays. Now I want to change label color of checkbox which gets updated by getCheckStatus(itemId, $root.AllAssignedTickets).

Can the function be made observable to update CSS real time when checkbox is checked or unchecked?
0
Script for copying field values doesn't work in jquery-heavy site. How do I modify this to restore functionality? The script used to work fine, but when the application was upgraded and started using lots of jquery vs. the old stuff, the script stopped working. Is it merely a question of adding $(document.ready() { ...   to the right place?

<script language = "JavaScript">
               function copyToBusiness()
               {
       var f=document.forms["aspnetForm"];
       f.elements["ctl00$ctl00$mpcSingleContent$cntrlID_11155"].value = f.elements["ctl00$ctl00$mpcSingleContent$cntrlID_11148"].value;
        f.elements["ctl00$ctl00$mpcSingleContent$cntrlID_11154"].value = f.elements["ctl00$ctl00$mpcSingleContent$cntrlID_11147"].value;
               }
</script>

<a href="javascript:copyToBusiness()">Click to copy the Business Address below</a>
0
HTML5 and CSS3 Fundamentals
LVL 13
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

dear all

i have a xml file
var m_XML_segments_Grid =  ($.parseXML(m_result_segments_Grid); where m_result_segments_Grid is an string
and m_XML_segments_Grid_str = new XMLSerializer().serializeToString(m_XML_segments_Grid);
contain the below :
"<NewDataSet>↵  <DsResQuery>↵    <SEQ>2</SEQ>↵    <SEGMENTNBRE>Segment #1</SEGMENTNBRE>↵    <P_SEGID>1</P_SEGID>↵    <CBOIN>08:00</CBOIN>↵    <CBOOUT>13:00</CBOOUT>↵    <DATE_TIME_STR>09/02/2019</DATE_TIME_STR>↵    <P_DESC>Segment 1 desc</P_DESC>↵    <P_DSCHEMA>8</P_DSCHEMA>↵    <P_WRKSTAT>0</P_WRKSTAT>↵    <P_PRESENT>1</P_PRESENT>↵    <P_STATUS_DAY>0</P_STATUS_DAY>↵    <P_FLOAT>0</P_FLOAT>↵  </DsResQuery>↵  <DsResQuery>↵    <SEQ>3</SEQ>↵    <SEGMENTNBRE>Segment #2</SEGMENTNBRE>↵    <P_SEGID>2</P_SEGID>↵    <CBOIN>14:00</CBOIN>↵    <CBOOUT>17:30</CBOOUT>↵    <DATE_TIME_STR>09/02/2019</DATE_TIME_STR>↵    <P_DESC>Segment 2 desc</P_DESC>↵    <P_DSCHEMA>8</P_DSCHEMA>↵    <P_WRKSTAT>0</P_WRKSTAT>↵    <P_PRESENT>1</P_PRESENT>↵    <P_STATUS_DAY>0</P_STATUS_DAY>↵    <P_FLOAT>0</P_FLOAT>↵  </DsResQuery>↵</NewDataSet>"

Open in new window

i need to add row to this xml and delete row from this xml how to do it?
1
Hi
In order to prevent another $thousands mess with Godaddy, I thought I'd get some advice on my new circumstance.

A Godaddy tech is calling me tomorrow to discuss my unused policies and perhaps a refund on my giant mistake.

If you'd like a remembrance of the  previous blunder question, briefly, it is here

Anyway, the tech suggested I might be refunded this $3,000, he said -
$1,000 dedicated server purchase (and some other stuff) and we'll discuss it tomorrow. I'll let you know how it goes here, and on my other question.

Discussion with Godaddy tech -
I'll say - Experts advised me to stop using godaddy. - for hobbyists, which I have already done a hobby type blog.
Sadly, I have a bad case of loyalty tendency....no more...
I mentioned on the setup call today that experts had advised me that Godaddy was inadequate for top-shelf .io game delivery.
How pitiful.
I don't even know why I fell for the $3,000 thing. She convinced me it would be optimal for game delivery and speed. My blog's performance seemed acceptable, but it wasn't NYT. I saw no reason to be contemptuous.
Is there any chance the tech could offer something decent tomorrow? Don't I want to keep my godaddy for the parked domains and my many files and backups in my public folder, ability to do new websites quickly? The refund will only be into my Godaddy account, which might …
0
Hello Experts,

Recently I have had reports that customers can make $0 Value  purchases with the default 1111 promo from https://cart.citysightseeingtoronto.com/

I realize that now if you leave all passengers as 0 you can still continue, I will fix this. However, real purchases with >0 passengers (not just infants) are going through with $0 being charged.

Is anyone able to make such $0 purchases? If so, I would greatly appreciate how to replicate/fix. I would also appreciate if I can get  the confirmation number they get, so that I can void it.

Since this is coming from the general public, I do not have the type of browser used, etc. As you'll also note this is a legacy app in Classic ASP, but if needed, I was hoping if someone can give e a pointer on how to get and store the client (browser) info,  so I can add it to a field for analysis? I'm  drawing a blank, would this be a part of the equivalent of $_SERVER, or js header()?

Any help will be appreciated.
0
I have the following regex (see onkeyup) that automatically inserts a slash (/) in between the 2-digit month, 2-digit day and 4-digit year, but now I want my users to only enter the 2-digit month and 2-digit year. Could someone please help me modify the below regex to achieve this?

Enter MM/YY: <input type="text" id="myDate" name="myDate" maxlength="10" style="width:80px;" onkeyup="this.value=this.value.replace(/^(\d\d)(\d)$/g,'$1/$2').replace(/^(\d\d\/\d\d)(\d+)$/g,'$1/$2').replace(/[^\d\/]/g,'')" />

Many thanks in advance.
0
In front end development I came across a page where there was a side bar, with a page that could scroll.

Is there a name for this effect and how could I create it? (Screenshot attached)
Screenshot-from-2019-10-10-17-34-24.png
1
When using JavaScript to write and Microsoft Active Directory Distinguished Name (DN), how should the spaces in an OU name be written?
Example: var from = "CN=TestSvrName,OU=Server Admin Groups,OU=AdminGroups,OU=Admin,DC=COMPANY,DC=COM";
Notice the spaces between Server Admin and Groups.
My code is returning error: NameErr: DSID-03100238, problem 2001 (NO_OBJECT), data 0
0
Good morning all !

I added the intl-tel-input module to my site and combined the formatting of the phone numbers when the user chose his country.
Good it works, if I choose Ivory Coast 07 12 34 56
But if I choose France: 06 12 34 56
however the number of France for example it is: 06 12 34 56 78
Here is all my code:
var input_1 = document.querySelector("#Fr_Telephone_1");
var intl_1 = window.intlTelInput(input_1,{
  initialCountry : "ci",
  preferredCountries : ['ci','sn','tg','cd','fr'],
  geoIpLookup : function(callback){
    $.get('https://ipinfo.io',function(){},"jsonp").always(function(resp){
      var countryCode=(resp && resp.country) ? resp.country : "";
      callback(countryCode);
    });
  },
  utilsScript : "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/16.0.0/js/utils.js"
});

var handleChange_1 = function() {
var text_1 = intl_1.isValidNumber()? intl_1.getNumber() : "";
document.getElementById("Fr_Phone_1").value = text_1.replace('+','00');
};
document.querySelector("#Fr_Telephone_1").addEventListener('change', handleChange_1);
document.querySelector("#Fr_Telephone_1").addEventListener('keyup', handleChange_1);

var mask_1 = $("#Fr_Telephone_1").attr('placeholder').replace(/[0-9]/g, 0);
$(document).ready(function () {$('#Fr_Telephone_1').mask(mask_1)});

$("#Fr_Telephone_1").on("countrychange", function (e, countryData) {
    $("#Fr_Telephone_1").val('');
    var mask_1 = $("#Fr_Telephone_1").attr('placeholder').replace(/[0-9]/g, 0);
    

Open in new window

0
Hi
How does Javascript code find external html objects to modify? Javascript written inside HTML <script> tags is a simple connection to the HTML objects id'd in the HTML

In my index.htm below, I print out the result of (11+5) inside a named paragraph object id

If I change that print line to "innerHTML.js" which contains that exact line of code, getElementByID can't find the "demo" paragraph

My index.htm is:
<p>
<!DOCTYPE html>
<html>
<body>

<h1>Outer HTML object demo</h1>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 11+5
</script>

</body>
</html>

Open in new window

</p>
Then, if I change the line that prints 11+5 on the "demo" paragraph object to a<script src=...> .js file with that line of code in it,

it doesn't connect.
How does the javascript file called from the HTML link back to a paragraph object in the HTML?

Thanks
0
Hi
As it is, I think I am nearly ready to start fleshing out my .io game in javascript.

Do .io game coders get the width and height of the game screen and do % locations in the code for objects, text and pics? - so rotation layout and size adjustment is covered? How is rotation best managed? does a listener call for a redraw after a rotation is complete? and new %'s are aligned? how?

How might a layout look that shows any linked pic at an appealing size in landscape and then adjust to another config on portrait?


Thanks
0
Exploring SharePoint 2016
LVL 13
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

I have a ticketing system which is written in KnockOut using template. Template structure is as below This template is repeated for multiple users on a page. In this parent.AssignedTickets is a list of Ticket Id assigned to users. So system has multiple TicketIDs and if it is assigned to user then it shows checked.

I want to change label color if checkbox is checked.

<script type="text/html" id="TicketAssignmentTemplate">
    <td>
        <label>
          <input type="checkbox" data-bind="checkedValue: TicketId, checked: $parent.AssignedTickets" />
        </label>
    </td>
    <td>
        <label data-bind="text: title"></label>
    </td>
</script>
<style>.success{background-color: #DFF0D8;}</style>

Open in new window



I tried data binding label css: {success: !$parent.AssignedTickets} but that did not work. Surprise! It can't be that simple. Any other thing I can try?

Part 2. Reason, I want this label highlighted is because supervisors who assign Tickets know which Tickets are already assigned. So this Label color should be highlighted in other TicketTemplate of other users too. I think that will require having a list defined across multiple users and updating it real time as tickets get assigned.
0
I think that I understand these concepts, but

First as I know 'event propagation' is divided into 3 phases:
1. Capture phase
2. Target phase
3. Bubbling phase.
if we have a hierarchy as
Window --> Document --> <html> --> <body> --> <div.container> --> <div.card> --> <div.card-title>,

for example, if we have a click event on card-title, then during Capture phase it will start from Window, executing event handler attached to each element.
And once it comes to card-title, it's entering Target phase. We can use "Capturing" by passing 'true' to addEventListener.
Window --> Document --> <html> --> <body> --> <div.container> --> <div.card> --> <div.card-title>

Bubbling is a default behavior, so when we click 'card-title', it executes event handler that is attached to card-title, but it goes up till Window and execute event handlers that are attached to each element, correct? Window <-- Document <-- <html> <-- <body> <-- <div.container> <-- <div.card> <-- <div.card-title>

So I believe that these are they way you can propagate events.

What I am really clear is the difference between "event capturing" and "event delegation".
In event delegation, we put the event listener to the parent element. Then, it goes down to its children.  Like when we put the event handler on ul, that event handler will be executed for all the <li>s under this ul.  
However, in here we are not passing 'true' on addEventListener, right?
And children don't have any event handlers …
0
Good moning !

I use this code to edit the quantity of products from a button. With Chrome it goes very well but with Firefox it sends me an ajax error.
This happens when I change quantities quickly.
If I click on Chrome several times, everything is fine, but on firefox it crashes.
Can you guide me please?

function BTN_EDT(i){
	var $button = $(this);
	var val_R = document.getElementById("ARR_NumId_" + i).value;
	var val_Q = document.getElementById("ARR_Quantite_" + i).value;
    $.ajax({
		type : "POST",
        url: '_produit-update.php',
        cache: false,
		data: {val_R:val_R, val_Q:val_Q},
        error: function(e){console.log('Ajax Error',e);alert('Erreur Ajax');},
        success: function(response){console.log('Ajax Success',response); location.reload(true);}
    });
}

Open in new window

Thank you in advance
0
HI, I am new to CORS. I have a question about it.
I have a js post call to web service API , but got an error in my local:
"Access to XMLHttpRequest at 'https://xyz.com/X/gettoken' from origin 'http://localhost:8080' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:8080, *', but only one is allowed. "

I see in my java code, there are some code  which add "resp.header("Access-Control-Allow-Origin", "*")". I removed it, and compiled and run, still get the same result.
Any inputs will be appreciated!
0
Hi, in the Xcode IDE for javascript,

How do I setup this example code correctly?
This example will get me going full speed ahead..
ie, what do I name the html section and the javascript section? (labeled "the code used is:")
and do I copy the entire code section into its own file? Separate would be better.
Also, there is no <script...> code to link the code into the HTML
Should I add that anywhere before?
where it says, "the HTML markup is:"

Also..What else must be done to get this working? What are some exploitable mistakes I can make? How do coders make it simple to code swipe games w/o using a phone for test?
Link the mouse in to the swiping? How?
Can you see the PNG's for the arrow pics?
The code first example page is here

Maybe this page is better? here

Thanks
0
Hello Experts

I am looking for a little direction on a project.  It may be preference, but how do you all start and go about writing your code?


The project will use node, express and mySql with a a react/handlebar front.  The user will add, update, view and report on records of entry.  


Do you start with your front side user entry skeleton? Or do you start with the back side getting the database connected and the server created and work forward?


Thanks,
Ed
0

JavaScript

123K

Solutions

42K

Contributors

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.