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

hi

how can i remove a node from html collection xml in javascript
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!

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
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
OWASP Proactive Controls
LVL 13
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

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
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
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
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
Why Diversity in Tech Matters
LVL 13
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Hi Experts,

I have the following JS code set certain fields as required.

// set required to true or false
function setRequired(flag) {
  if (flag == true) {
    // get the current sig, default = []
    var sig = $('input[name="output"]').val();
    $('#cb_sign_wrapper').signaturePad({drawOnly : true}).regenerate( (sig) ? sig : [] );

    $('.req').each(function() {
      $(this).closest('tr').next().find('input').attr('required',true);
    });

    $('.req').each(function() {
      $(this).closest('tr').next().find('textarea').attr('required',true);
    });

    $('.req').each(function() {
        $(this).closest('tr').next().find('select').attr('required',true);
    });
  } else {

    $('input:required').each(function() {
      $(this).prop('required',false);
    });

    $('textarea:required').each(function() {
      $(this).prop('required',false);
    });

    $('select:required').each(function() {
      $(this).prop('required',false);
    });
  }
}

Open in new window


Wondering if there is a way to prohibit users from entering N/A or NA on these fields?

Thanks
0
Hi Experts,

How can I change the code below to

1- Only popup once.
2- Do not let the user exit the field without either entering required quantity of characters or leave it blank.

   $("textarea[id*=Treatments_Administered]")
       .attr("minlength", 100)
       .on("change blur", function() {
           if($(this).val().replace(/^\s*|\s*$/g,"").length<100) {
               alert("You must enter at least 100 characters!");
           }
   });

Open in new window


Thanks
0
jQuery (Javascript libraries) are bundled with a number of our
softwares (Weblogic, a supplier app, mobile app): quite a number
of XSS vulnerabilities were found by our pentester.

Q1:
One app vendor replied that updating (ie patching) or upgrading
jQuery may destabilize their app?  So are we supposed to wait
for these vendors to release their next release app so as to
bundle in newer & patched jQuery or we can get the patches/
updates from Oracle & just update/patch it??   Or by doing so,
we'll lose the support of the app vendor?

Q2:
In the case of Weblogic 12.2.1.3, jQuery ver 3.2 is bundled.
Since both Weblogic & jQuery are from Oracle, is it supported
if we just update jQuery (or there's no patch/update ie we
just have to upgrade jQuery to ver 3.3 or 3.4)?

Q3:
Is jQuery vulnerabilities the same as javascript (read at Oracle
site that jQuery is actually  javascript library) vulnerabilities?
0
I have some html code using  JavaScript for multiple countdown timers on one page.
I am trying to figure out how to insert some code to play a sound when any of the timers hit zero.  My attempts to add any code at all breaks the timers, I'm just not sure what or where to put code for audio.
Can anyone point me in the right direction?

This is the working code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
	margin-top: 0px;
	margin-bottom: 0px;
}
</style>
</head>
<body>
<table width="358" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr>
    <td width="100" align="center" valign="bottom"><input id="timer1" type="button" value="40 sec" style="width:100px" /></td>
    <td width="50" align="center" valign="bottom"><div id='countdown1'></div></td>
    <td width="26" align="left" valign="bottom">&nbsp;</td>
    <td width="100" align="center" valign="bottom"><input id="timer3" type="button" value="90 sec" style="width:100px" /></td>
    <td width="50" align="center" valign="bottom"><div id='countdown3'></div></td>
  </tr>
  <tr>
    <td align="center" valign="bottom"><input id="timer2" type="button" value="60 sec" style="width:100px" /></td>
    <td align="center" valign="bottom"><div id='countdown2'></div></td>
    <td align="left" valign="bottom">&nbsp;</td>
    <td align="center" valign="bottom"><input id="timer4" type="button" value="120 sec" style="width:100px" /></td>
    <td 

Open in new window

0
Hi

For my phone game, I have received a lot of Expert advice, - no 'pay to win' - 'not too many ads' - 'focus on gameplay.'
I haven't bought anything on a game yet. On 'wordscapes,' I have watched ads to gain coins. That seems to be a winner for them.
Compared to a blog, what are Adsense for games - CPM's and CPC's like for publicity and generating revenue?


Thanks.
0
Here's my code:

require("dotenv").config();

const express = require("express");
const mongoose = require("mongoose");
const csrf = require("csurf");
const bodyParser = require("body-parser");

const app = express();
const conn = process.env.CONNECTION;
const csrfProtection = csrf();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(csrfProtection);

const loginRoutes = require("./routes/login");
const authRoutes = require("./routes/auth");
const createRoutes = require("./routes/create");

app.use((req, res, next) => {
  res.locals.csrfToken = req.csrfToken();
  next();
});

app.use(loginRoutes);
app.use(authRoutes);
app.use(createRoutes);

mongoose
  .connect(conn)
  .then(result => {
    app.listen(5000);
  })
  .catch(err => {
    console.log(err);
  });

Open in new window


I'm getting an error that says my csrf token is misconfigured and I don't know what to do or where to start.

Here's the whole error:

Error: misconfigured csrf
    at csrf (C:\wamp\www\authentication\node_modules\csurf\index.js:71:19)
    at Layer.handle [as handle_request] (C:\wamp\www\authentication\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\wamp\www\authentication\node_modules\express\lib\router\index.js:317:13)
    at C:\wamp\www\authentication\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\wamp\www\authentication\node_modules\express\lib\router\index.js:335:12)
    at next 

Open in new window

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.