Go Premium for a chance to win a PS4. Enter to Win

x

JavaScript

120K

Solutions

41K

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 be able to track a member of my service or someone who clicks from my site to access a merchant.

I think this would be in the form oof a browser add on that would be like a cookie containing unique data for that user and to direct affiliate funds back to the account on my site.

I welcome possible solutions particuarly from anyone who has already dealt with this problem.

For Windows and Mac

Thak you.
0
Hi everyone !

A little help will be very much appreciated.

So here is the setup :
We have a NSA 2600 BASE (only access rules and vpn, not licence for anything else no web filter whatsoever...)
All user have Windows 10
all Internet is working but 1 only one that have massive delay!!!
www.tenaquip.com

now here is the weird part ....

 Last week,  everything is fine everything works (made no change on the firewall or the network whatsoever)
This Monday on day 1 that website is down and teniquip.com knows it.
Day 2: its up again so they told us, we try it here massive delay but it work, with massive delay.
I try it home and it is just fine. Reboot the firewall clear the cache, same problem ... massive delay ...
Day 3: Update NSA firmware same problem ...Hotspot a laptop and it work fine no delay, put the laptop on the LAN and same problem, massive delay.

CLUE:
So i disable Javascript on the laptop and NOW the website is opening really fast BUT i cannot put item on the basket, to do so i must enable JAVASCRIPT and once enabled again it CAUSE massive delay !! all pc here have the same issues...

keep in mind everything was working fine last week and nothing had change on my network !

On the NSA, i try:
Enable TLS compatible mode and Enforce Host Tag Search for CFS (diag mode)
Nothing work
0
I'm working on the Jquery to create the validation for employee portal. I'm having the columns like name, email id, doj, reporting etc. like the things. If the column is empty it need to show dialog warning or dialog window.

I have used the below Jquery,

var apiHost = "";
var apiResUrl = "/v1/resources";
var apiAddNewEmployee = "/addemployee";
var err = "/dialog";
var addEmployee = function() {
var data = $(newEmpForm).serializeArray();
$(".successMSG").hide();
$(".errorMSG").hide();
$.ajax({
url: apiHost + apiResUrl + apiAddNewEmployee,
type: 'POST',
data: JSON.stringify(data),
headers: { token: $.cookie('token') },
contentType: "application/json",
error: function(err) {
$(err).dialog();
},
success: function(data) {
if (!isEmpty(data.response.status) && data.response.status.toLowerCase() == "invalid") {
alert("Naga Test Boo");
} else {
if ((data.response.message != undefined) || (data.response.message != "")) {
$(".successMSG").text(data.response.message);
$(".successMSG").show();
}
searchEmployees(false);
$(".successMSG").delay(3000).fadeOut(2000);
$(".errorMSG").delay(3000).fadeOut(2000);
}
}
});
};

var loadEmployee = function() {
var page = 1;
empajax("sort:descending AND (-id:1000)", page);
$("#navigationdiv").hide();
$("#searchdiv").show();
$("#custompanel").show();
$(".successMSG").hide();
$(".errorMSG").hide();
$("#addEmp").on('click', function() {
$("#empID").val(getEmployeeID());
$('#new-employee').modal('show');
});
datepic($("#datepicker"));

Open in new window

0
Dear Experts,

I have a calculation like below, but the result is 135.51999999999998,
how can I round it with two decimals 135.52 ?

 document.getElementById('a13').value = parseFloat(fifth)*parseFloat(sixth);

Open in new window


thank you
0
I need an example that shows credit card type while typing

.Net page

I am using stripe but their custom elements don't show the icon
0
I need a method of preventing two (or more) embedded audio streams (embedded in a HTML file) from being played simultaneously.  The HTML code currently being used is the following:

<div align="left">
<p style="text-indent:0em">
<audio controls>
<source src="http://myside.com/Part_1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</p>
</div>
<div align="left">
<p style="text-indent:0em">
<audio controls>
<source src="http://myside.com/Part_2.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</p>
</div>

Open in new window


Currently there is nothing to prevent the user from playing both streams at the same time. I need some method to prevent this from happening. I need a solution that, no matter how many embedded streams are included in a single HTML file, only one stream will play at any given moment.
0
Have code that works in JSFiddle

https://jsfiddle.net/ywain/L96q8uj5/

But when I pl;ace all of that code in my page

Everything loads and looks fine

Only the brand-icon never changes.
0
I have a responsive site using a jQuery click event that toggles a semi-transparent slide when the user clicks on a thumbnail image. The script works as expected on desktop, but not at all on mobile.

Here is my jQuery script:

jQuery(document).ready(function() {
    jQuery('.image-frame').click(function(){
            jQuery('.image-caption',this).slideToggle('slow');
      }, function(){
            jQuery('.image-caption',this).slideToggle('slow');
    });
});


The site is located at http://www.albanyneca.com and the script fires on the 6 thumbnail images found on the home page.

I can't figure out why the click event doesn't work on mobile?
0
I have an existing html page with bootstrap 3 snippet to open modal popup as below

link to open modal pop up

<a href="#" class="fa fa-search FA_Ico mT5" aria-hidden="true" title="SearchOrg" data-toggle="modal" data-target="#SearchAccountModal"></a>

Open in new window


modal pop up

<div class="modal fade modal-xl" id="SearchAccountModal" tabindex="-1" role="dialog">
	//additional code 
</div>

Open in new window


when I click  the above link , modal pop up opens fine....no problem.

Now my question is : What would be the angularjs way to open the same modal pop up ?

I'm using angularjs 1.3
0
hello expert,
can somebody here help me on how to make the result of this calculation always round of to 2 decimal

<script>
        var x = 0;
        var y = 0;
        var z = 0;
        function calcluar(obj) {
            var e = obj.id.toString();
            if (e == 'panjang') {
                x = Number(obj.value);
                y = Number(document.getElementById('lebar').value);
            } else {
                x = Number(document.getElementById('panjang').value);
                y = Number(obj.value);
            }
            z = x * y;
            document.getElementById('keluasan').value =  z;
        }
</script>


<div style="margin-bottom:10px; margin-top:10px; margin-left: 10px;">
    <label style="margin-right: 20px;">Ukuran (m)  </label>
    <input type="text" style="width:8%;" labelWidth="80px" id="panjang" name="PANJANG" onkeyup="calcluar(this)" placeholder="P"> X
    <input type="text" style="width:8%;" id="lebar" name="LEBAR" onkeyup="calcluar(this)" placeholder="L"> =
    <input type="text" style="width:8%;" id="keluasan" name="KELUASAN" onkeyup="calcluar(this)">
</div>    

Thanks for you help
0
As title is saying i am trying to send variable from js to php. But no success: I am getting "1" as echo.
 Can You tel me from the code i am providing here what is wrong?


function saveToProjectsListF(){
 
$.ajax({
  type: 'POST',
  url:'/wp-content/themes/net4/user.php',
  data: {"actualproject": weGotTheuserHahaHa+"123"},
});
   
}

Open in new window

     
<?php
if(isset($_POST["actualproject"])){
	$actualproject = $_POST["actualproject"];
}else{
    	$actualproject="1";
}
?>

Open in new window


 <p><?php echo $actualproject; ?></p>  

Open in new window

0
I use the function below to convert a SharePoint date value that is pre-populated in an html form to a regular date.

var spDate = "1987-02-28T23:11:81.333 ";

alert(convertSPDate(spDate))

function convertSPDate(d) {

	    // split apart the date and time
	    var xDate = d.split("T")[0];

	
	    // split apart the year, month, & day
	    var xDateParts = xDate.split("-");
	    var xYear = xDateParts[0];
	    var xMonth = xDateParts[1];
	    var xDay = xDateParts[2];
	var dDate = xMonth+"/"+xDay+"/"+xYear;
	   
	    return dDate;
	}

Open in new window

Unfortunately, if the field is blank, I get the SCRIPT error
Unable to get property 'split' of undefined or null reference

In jsFiddle, I get undefined/undefined/
https://jsfiddle.net/isogunro/qxf3a6r4/3/

Any help would be much appreciated.  THanks!
0
I want to detect if a variable contains either "branch-result" or "App/Locator". What would be the best approach?

Thanks!
0
Hi whats the best, quickest and easiest way to style positive (blue) and negative (red) numbers in an asp page. Code is below and I'm using a CSS include to style stuff... Thanks


table {
    border-collapse: collapse;
    width: 100%;
}

th{
	background-color: #87C5FF
		font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-align: left;
    padding: 9px;
	font-size:11px;
}
td {
	font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-align: left;
    padding: 9px;
}
tr:nth-child(odd){
	font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size:10px;
	background-color: #eef6ff
	}
tr:nth-child(even){
	font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size:10px;
	background-color: #ffffff
	}

Open in new window



<%
   Set objXML = Server.CreateObject("MSXML2.DOMDocument.3.0")
   objXML.async = False
	objXML.Load (Server.MapPath("book/NWP-MV.xml"))
	
	
'select each node in the data
	For Each xmlNode In objXML.documentElement.selectNodes("Data")

		'strTitle = xmlProduct.selectSingleNode("EnsembleID").text

     xIssue = xIssue & xmlNode.selectSingleNode("Issue").text & ","
	 xEnsembleID = xEnsembleID & xmlNode.selectSingleNode("EnsembleID").text & "," 
    ' xBookCode = xBookCode & xmlNode.selectSingleNode("BookCode").text  & ","        
     xStatistics = xStatistics & xmlNode.selectSingleNode("LongBLPTicker").text & ","
	 xStubPos = xStubPos & xmlNode.selectSingleNode("StubPos").text 

Open in new window

0
Hello There

i am a VB.net programmer by trade.  But now I am  coding some javascript and am having a bit of trouble.  I have an HTML page that has some script in it that runs behind a button click.  At the  end of the code, I need to popup a "modal form" that has a picture on it with some text.

I have searched the net and have seen many different variations but cannot seem to find one that I can make work.  What is the best way to popup a modal?

Thanks,
jimbo99999
0
How come the following does not work? What am I doing wrong?


<input type="text" id="ssn" placeholder="xxx-xx-xxxx">
<button id="ssValidate" onclick="valSSN()">
Validate
</button>

function valSSN(){
	var ssn = document.getElementById("ssn").value;
  var regExpression = /^[/d{3}]-[/d{2}]-[/d{4}]/;
  if(regExpression.test(ssn)){
  	alert("valid");
  }else{
  	alert("invalid");
  }
}

Open in new window



https://jsfiddle.net/isogunro/b3qdvufy/1/
0
I had this question after viewing JSON Terminology - Block or Object/Closer to Java or JavaScript.

Hello again,

I found some JSON similar to the below when running a query:

[
  { 
     time: "15:00",
     temperature: 66
  },
  {
     time: "17:00",
     temperature: 62
]

Open in new window


Is it legal to have an array as the outer entity here? Or, do they need an outer ( } to make it an object? I looked at:
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf

but can't tell for sure.

Thanks!
0
I am playing with a puzzle program where certain puzzle pieces will have information to share, and those are the ones with a "dog-ear" on the upper corner.

Sample
Those with a dog-ear will respond differently to user interaction and each will have images, videos and/or help text, explaining what's so special about the selected  puzzle piece. There could also be a left-click or a right-click which opens an enlarged version of a given puzzle piece, so the user can get a close-up.

I need some ideas about how to present this information to the user. I am not sure what types of click or clicks would be used to bring up what probably would be a menu of options.


Suggestions?
0
Here i the CSS I use to create the dark corner in the upper-right.


.dog-ear {
	position: absolute;
	top: 0;
	right: 0;
	height: 10px;
	width: 10px;
	background: linear-gradient(45deg, #333 0%, #333 50%, #fff 50%, #fff 100%);
}

Open in new window



But It sometimes looks choppy.

Choppy line
Is there a different way to do this?
0
I try to follow the tutorial on https://gamedevelopment.tutsplus.com/tutorials/create-a-simple-space-shooter-game-in-html5-with-easeljs--active-10944 and I have hard time figure out why there is problem connect to the external EaselJS library. Any suggestions are appreciated.

HTML

<!DOCTYPE html>
<html>
	<head>
		<title>Shooter</title>
		<style>
			/* Removes Mobile Highlight */ * {
				-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
			}
		</style>
		<script src="easel.js"></script>
		<script src="Tween.js"></script>
		<script src="Main.js"></script>
	</head>
	<body onload="Main();">
		<canvas id="Shooter" width="320" height="480"></canvas>
	</body>
</html>

Open in new window


Main.js

/* Define Canvas */

var canvas;
var stage;

/* Background */

var bgImg = new Image();
var bg;
var bg2Img = new Image();
var bg2;

/* Ship */

var sImg = new Image();
var ship;

/* Enemy */

var eImg = new Image();

/* Boss */

var bImg = new Image();
var boss;

/* Lives */

var lImg = new Image();

/* Bullets */

var bltImg = new Image();

/* Alert */

var winImg = new Image();
var loseImg = new Image();
var win;
var lose;

var lives = new Container(); //stores the lives gfx 
var bullets = new Container(); //stores the bullets gfx 
var enemies = new Container(); //stores the enemies gfx 
var bossHealth = 20;
var score;
var gfxLoaded = 0; //used as a preloader, counts the already loaded items 
var centerX = 160;
var centerY = 240;
var tkr = new Object(); //used as a Ticker listener 

Open in new window

0
How can I remove the button and make it that if $_POST['a'] == 1
Then display the pop up? else dont? Is this possible?

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <p>Some text in the modal.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

Open in new window

0
I would like to call the sub on my page.aspx.vb page using the existing JavaScript function


Public Sub doDataCall()
   ' Do sub code here
End Sub

Here is my page html button
I cannot switch to .net button
There is a LOT of css applied to the button and any change I attempt to make leads to a disaster elsewhere

            <button onclick="doFunction();">Pay <asp:Label ID="lblAmount" runat="server"></asp:Label></button>

JavaScript current function
I need to pass in foo to the vb sub

    <script type="text/javascript">
        function doFunction() {
            var uri = window.location.href;
            var lastslashindex = uri.lastIndexOf('/');
            var result = uri.substring(lastslashindex + 1);
            alert(foo);
        };
    </script>

Open in new window

0
Hi,
I'm writing an API guide for an application that accepts input - and generates output - in JSON format.

Suppose I have the following (redacted) code:
{
   SSN :  "012-34-5678",
   DOB: "1986-10-27",
   Age: 30,
   name: {
      first: "Daffy",
      last : "Duck"
    },
   Department: "Sales"
}

Open in new window


1. Is this entire entity referred to as a block or object?
2. Same for the name element, which contains first/last name.

Also, is JSON syntax considered closer to Java? Or to JavaScript?  The reason I need to know the latter is that I'm showing code samples in Confluence. While Confluence has a Code Block Macro, it does not come with prepackaged JSON formatting.

Thanks,
Steve
0
I added a class to a div, and verify the booelan's working.  But, the ng-class is failing.

    <div ng-class="{ 'dog-ear' : isDogEared }"></div>

Open in new window


Inside the Typescript template I have:
@Output() isDogEared:boolean;

  dogEarIndexes: number[];

  constructor() 
  { 
    this.dogEarIndexes = [ 1,3,5 ];
  }

  ngOnInit() {
    this.imageFilename = "PuzzlePiece_Maps_" + (this.value.id + 1).toString() + ".gif";
    
    this.id = this.value.id;
    this.isDogEared = this.dogEarIndexes.indexOf(this.id) > -1;
    console.log('Id:'+this.id+" - " + this.imageFilename + " isDogEared="+ this.isDogEared.toString());    
  }

Open in new window


and the page does not generate any errors, and I verified the boolean values are properly set in ngOnInit()

Booleans Work OK

What am I missing?
0
Dear,
What to adjust below
                html += "<tr class='houserow' data-id='" + house.house_id + "'>";
                html += "<td >" + (site_lang === "ENG" ? "Price: " : "") + "</td><td >" + house.price_curr + "</td>";
                html += "<td >" + house.price + "</td>";
                html += "<td >更新日期</td><td >" + house.upd_date + "</td>";
                html += "</tr>";

Open in new window


to have more columns below
19c.pngto this site?                        

http://my-friend.co/HouseList4/Default.aspx?userid=mc23
0

JavaScript

120K

Solutions

41K

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.