JavaScript

121K

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

How to Detect Traffic From China language hu-hu (reported in google analytics) and divert to a not available in your region page

I notice traffic with language hu-hu in my google analytics with a high bounce rate.

What is the best way of detecting traffic from China -   with language hu-hu?

I have a cold fusion 2016 site.  Thank you
0
Introducing Cloud Class® training courses
LVL 12
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

I have this HTML code (generated by php). This produces a blank screen:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="simpleLightbox.min.css">     
<script src="simpleLightbox.min.js"></script>
<title>IND Lakos Configurator - Modify Trade Price</title>
<style>
.nopadding {
   padding: 0 !important;
   margin: 0 !important;
}
.wrapper{
  max-width:1100px;
  min-width:900px;
  margin:0 auto;
  
}
#dialog { text-align:center; }
.custom-overlay { background-color: black; background-image: none; opacity: 0.4; } 
</style> 
 <style type="text/css">
        .contentInPopup { padding: 2em; max-width: 40em;}
		.contentInPopup p { font-size: 1.3em; font-family: Arial, Helvetica, sans-serif; }
        </style>
<script type="text/javascript">
$(document).ready(function() {
            $('#click').click(function() {
                $.SimpleLightbox.open({
                    content : $('#myContent').html(),
          

Open in new window

0
This is intersting that I didn't know. The thing is per this https://api.jquery.com/visible-selector/  the element should be visible. I see it in the DOM

 1. I have a page and I changed the design to have tabs
2. Original code didn't have tabs. It's one long page.
3. It does this

	var visibleSchedules = $(document).find('#scheduleArea .schedule:visible');

	if (visibleSchedules.length > 0) {...

Open in new window


4. With tabs (my redesign, when I'm not the corresponding tab... ".schedule:visible" is not visible

This is how I have it now:

t1.png
5. I thought instead of "visible", I should drill down to the dropdown in the div and check the selected value from the dropdown. If at least one not set to "select"...then I can loop thru this div like the old code. So, not look for "visible" because user might be on another tab

t2.png
I tried these but I get black for the what's selected in the dropdown

var visibleSchedules = $(document).find('#scheduleArea .schedule:visible');

         //********* tried this
	//var visibleSchedules2 = $(document).find('#scheduleArea .schedule').find('#Schedules[0].Type:selected').val();

       //******** tried this
	//var t = $('#Schedules[0].Type:selected').text()

	if (visibleSchedules.length > 0) {

Open in new window

0
I have the code below and what I am trying to accomplish is the field tType has a dropdown with company1 and company2

if company1 is selected Action="https://sharepointex3.dcs-xxx.com/sites/GSSTA/TA/LOAD/Lists/Opportunities/OppDetail.aspx"
if company2 is selected Action="https://sharepointex3.dcs-xxx.com/sites/GSSTA/TA/LOAD/Lists/Opportunities/OppDetail2.aspx"

<form id="form1" Action="https://sharepointex3.dcs-xxx.com/sites/GSSTA/TA/LOAD/Lists/Opportunities/OppDetail.aspx" method="GET">
<span class="style1"><strong>Opportunity Search Tool</strong></span><br />
&nbsp;<table style="width: 100%">
<tr>
<td style="width: 20%" class="style1">Enter the opportunity ID:</td>
<td><span class="style2"><span class="style3">
<input name="tOppID" id="tOppID" type="text" value="OPP-" style="width: 147px" /></span></span>&nbsp;</td>
</tr>
<tr>
<tr>
<td style="width: 20%" class="style1">Enter the opportunity ID:</td>
<td><span class="style2"><span class="style3">
<input name="tType" id="tType" type="text" style="width: 147px" /></span></span>&nbsp;</td>
</tr>
<tr>
<td style="width: 20%" class="style1">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="width: 20%" class="style1">
<input type="submit" value="submit" />
</td>
<td>&nbsp;</td>
</tr>
</table>
<br />
</form>

Open in new window

0
Hi

After researching heavily on why the delete query was failing in MS Access FE/SQl Server BE over the net and reading other IT books, it seems like the foreign key is cantered on the issues below:
INSERT and UPDATE Specification Category
I expanded the node to show information for the Delete Rule and the Update Rule for the relationship.
Delete Rule
It says specify what happens if a user tries to delete a row with data that is involved in a foreign key relationship:
•      No Action An error message tells the user that the deletion is not allowed and the DELETE is rolled back.
•      Cascade Deletes all rows containing data involved in the foreign key relationship. Do not specify CASCADE if the table will be included in a merge publication that uses logical records.
•      Set Null Sets the value to null if all foreign key columns for the table can accept null values.
•      Set Default Sets the value to the default value defined for the column if all foreign key columns for the table have defaults defined for them.
Update Rule
It says specify what occurs if a user tries to update a row with data that is involved in a foreign key relationship:
•      No Action An error message tells the user that the update is not allowed and the UPDATE is rolled back.
•      Cascade Updates all rows that contain data involved in the foreign key relationship. Do not specify CASCADE if the table will be included in a merge publication that uses logical records.
•      Set Null Sets the value to null if all …
0
Hello Experts,

I am trying to use browser back button to go to a specific URL. I used PlatformLocation in Angular to detect the popstate event. When I press the back button to go to the URL, it shows the previous angular route for fraction of seconds and then redirects me to the URL. I would like to eliminate that fickle from back button. So, it directly goes to the desired URL, without going to the previous angular route.

Thanks in advance.
0
Hello guys I'm having trouble sending data via aJax post to other page.
my code explain it all how might it supposedly works.

I want to send data from test.php to page.php while page document loads and dispaly also page.php to test.php if it really works.
To make it short how can I echo data:{tablename:tablename} to page.php

Here is my code
test.php
<?php
include ('include/head.php');
?>
<html>
<body>
<div class"showme" id="showme"></div>
</body>
</html>
<script>
$(document).ready(function(){
var tablename = "tbl_released";
{
	$.ajax
				({
					url:'page.php',
					method:'POST',
					data:{tablename:tablename},
					success:function(data){
					
					 }    
				});
				$("#showme").load("page.php");
			}
});
</script>

Open in new window

page.php
<?php
if(isset($_POST["tablename"])){
echo $_POST["tablename"];
}
?>
<html>
<body>
<h1>I am page.php</h1>
</body>
</html>

Open in new window

0
1. in javascript, how to get 15 from this url ? http://localhost:29792/Home/test/15
and
2. in javascript, how to get rid of "#' sign when I have http://localhost:29792/Home/test/15# ?

Thanks
0
Hi, I am populating a table using php. How can I get the value of 'JOB' from the table where the user clicks the checkbox. I have tried to add a class like previously suggested, but I cannot make it work.  I am attaching my code

while($row = $result->fetch_assoc()) {
        printf("<tr><id='traba'><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><input class='boxtocheck' type='checkbox' id='editar' name='editar' value='".e."' ><td></tr>",$row["fecha"], $row["job"],$row["tipo"],$row["valor"],$row["dinero"],$row["editar"]);
        $total=$total+$row["valor"];
        $total2=$total2+$row["dinero"];
        $jobs=$jobs+1;
    }
} else {
    echo "0 results";
}

Open in new window



<script>    
$(document).ready(function()
{
$('.boxtocheck').change(function() 
  {
    if(this.checked === true)
    {
// I am trying to see if the correct value is posted        y1 = document.getElementById('traba').value;
//                                                                                           console.log(y1);
         alert('Load page to edit');
    }
  });   
});    
</script>

Open in new window

0
I am populating a table with php, and I am adding a checkbox per ROW
I want to edit the CHECKBOX CLICKED , and with the code attached below, I am only checking THE FIRST ROW. Ex. if four rows are added, only the FIRST one is checked. I want to be able to check if the USER clicks ON ANY checkbox ROW
Tnx

while($row = $result->fetch_assoc()) {
        printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><input type='checkbox' id='editar' name='editar' value='".e."' ><td></tr>",$row["fecha"], $row["job"],$row["tipo"],$row["valor"],$row["dinero"],$row["editar"]);
        $total=$total+$row["valor"];
        $total2=$total2+$row["dinero"];
        $jobs=$jobs+1;
    }
} else {
    echo "0 results";
}

Open in new window

<script>    
$(document).ready(function()
{
    console.log('changed');
  $('#editar').change(function() 
  {
    if(this.checked === true)
    {
         alert('Load page to edit');
    }
  });   
});    
    
    
</script>

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Guys,

I need Help i am trying to add my failed Exchange Server 2010 to a DAG but when i ran the command in the image and getting the error. Please for your assistance.Adding-to-Cluster.JPG
0
Hi, I have a javascript countdown clock that throws this error:
TypeError: Cannot read property 'append' of undefined
 /micore/core/info/content_headlines.asp:832

Code:
    <script language="javascript" type="text/javascript">   
    var ringer = {
  countdown_to: "04/01/2019",
  rings: {
    'DAYS': { 
      s: 86400000, // mseconds in a day,
      max: 365
    },
    'HOURS': {
      s: 3600000, // mseconds per hour,
      max: 24
    },
    'MINUTES': {
      s: 60000, // mseconds per minute
      max: 60
    },
    'SECONDS': {
      s: 1000,
      max: 60
    }
   },
  r_count: 4,
  r_spacing: 20, // px
  r_size: 82, // px
  r_thickness: 10, // px
  update_interval: 11, // ms
    
    
  init: function(){
   
    $r = ringer;
    $r.cvs = document.createElement('canvas'); 
    
    $r.size = { 
      w: ($r.r_size + $r.r_thickness) * $r.r_count + ($r.r_spacing*($r.r_count-1)), 
      h: ($r.r_size + $r.r_thickness) 
    };
    


    $r.cvs.setAttribute('width',$r.size.w);           
    $r.cvs.setAttribute('height',$r.size.h);
    $r.ctx = $r.cvs.getContext('2d');
    $(".countdownwrap").append($r.cvs);
    $r.cvs = $($r.cvs);    
    $r.ctx.textAlign = 'center';
    $r.actual_size = $r.r_size + $r.r_thickness;
    $r.countdown_to_time = new Date($r.countdown_to).getTime();
    $r.cvs.css({ width: $r.size.w+"px", height: $r.size.h+"px" });
    $r.go();
  },
  ctx: null,
  go: function(){
    var idx=0;
    
    $r.time = (new Date().getTime()) - 

Open in new window

0
Usage of Bootstrap

I have done some reading online about Bootstrap, it states that Bootstrap includes HTML and CSS, and makes the web forms generated in easy and faster way.
I am not sure what they mean by that. DO they mean that when we open Bootsrop text editor we can write HTML and CSS on the same page ?
Another thing that I want to know is How does Javascript interact with Bootstrap ?

Thak you
0
I'm rewriting and improving some jQuery code that I have inherited from a developer who's not here anymore.

I got help from Leakim and Julian here and I'm using the same method (using Template) Previous question - long thread

1. I uploaded my sample code here https://drive.google.com/file/d/1d2Gn8UDfeHfXvn560b114i-5Ob2ZP8rJ/view

Just download, unzip and click on "page.html". The corresponding JS file is "Reporting.js"

2. When page loads, you'll see one row of dropdowns. Click "Add" and now you'll see two

e1.png
3. In the first row, select something from the first dropdown. The second dropdown in the first row is enabled. This is correct.
But, the second dropdown in the second row also is enabled. This is not correct. Why is this happening?

e2.png
4. There's some existing code that the ex-developer has in this section of
$(document).on('change', '#reportBuilder select.filterField', function () {...

Open in new window

of Reporting.JS.  I think something might be off in that section now that I'm using Template and divs. I'll debug that. I wonder if I need to have an ID on these dropdown? somehow say... if user selects something on this row...only make this row enable/disabled. All that code in the 'change' event is even needed? can it be simpilfied


EDIT I fixed it by changing the below code because I don't have "tr" and "table" anymore. Can that "change" function be simpilfied?
var operatorSelect = $('select.fieldOperator', $(this).parentsUntil('tr').next());

Open in new window


to this

var operatorSelect = $('select.fieldOperator', $(this).closest('div').next());

Open in new window

0
Hello,
I am creating a basic user authentication using nodejs, express.js and Passport.js.
I follow this example and it kind of works for me:
https://github.com/passport/express-4.x-local-example/blob/master/server.js

BUT, I would like to modify this demo to not have routes and not a template engine (ejs)

I have a folder with a bunch of static html files I would like to protect.
admin/
         /login.html
         /page1.html
         /page2.html
         /page3.html

I would like to password protect access to all html file under admin using basic authentication, but without routes.

In other words, I would like to access wepage.com/page2.html or any other html page and be redirected to login page, after logging in, I would like to be redirected back to page2.html and after that I could access the rest of the html pages without having to login. wepage.com/page4.html, wepage.com/page3.html, etc

The reason I don't want to have routes is because new html pages are added all the time and I don't want to keep creating routes for new ones or remove routes when deleting html pages.
Also, I don't really need a template engine since my pages are static html and I would like people to access the html directly. wepage.com/page1.html

The only requirements I have is nodejs, express.js and Passport.js.

Can someone please guide me or point me to an example to accomplish this?

Thanks
EMimi
0
My ASP.Net MVC web application have the following Javascript errors:
Uncaught SyntaxError: Unexpected token <
Uncaught ReferenceError: Sys is not defined
Uncaught ReferenceError: WebForm_AutoFocus is not defined

Open in new window


This is how it looks like in Firefox console:
Error
And these are the source code view of the relevant references and javascript.
Source
Source - javascript 1
Source - Javascript 2
How do the errors happen and how to fix them?
0
I have a php page and am trying to set the focus to a specific text input box when the page opens using this mechanism:

<script type="text/javascript" language="JavaScript">
	function jsSetFocus(){
		document.forms["OrderDetail"]["ProdnOrder"].disabled = true;
		document.forms["OrderDetail"]["VECode"].focus();
	}
	jsSetFocus();

Open in new window


my problem is that the focus event only fires intermittently - the ProdnOrder input is disabled but the focus is on the path in the address box which is highlighted. but occasionally the focus event works as it should.

How can I force the focus onto the VECode input box everytime?
0
i have some documents uploaded to the server , now i download each document alone
but i want to download all documents in just one click , any one can help .
using asp classic.
0
In Angular, Can I Create a Dynamic Table using Static and Dynamic Column header?


 
From the above example- Name and department are static content(hardcode values), 01.01.2015 , 01.02.2016, 01.03.2016 are dynamic content to be iterated using ngfor.
 
please provide solution in Angular 5
0
Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

In Angular, I need to create a Modal Window which contains a TextBox and a Button. But when i put some value in the text box of the modal window it's value is not updating?

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>  
    <script type="text/javascript">  
    var app = angular.module('myApp', []);  
    app.controller('myCtrl', function ($scope) {  
    $scope.firstName = "";  
    $scope.valSubmit = function () {  
    firstName = $scope.firstname;  
    alert(firstName);  
    $("#myModal").modal('hide');  
    };  
    });  
    </script>  
    </head>  
    <body ng-app="myApp" ng-controller="myCtrl">  
    <form id="form1" runat="server">  
    <div class="row">  
    <div id="myModal" class="modal fade" role="dialog">  
    <div class="modal-dialog">  
    <div class="modal-content">  
    <div class="modal-header">  
    <button type="button" class="close" data-dismiss="modal">×</button>  
    <h4 class="modal-title">Modal Header</h4>  
    </div>  
    <div class="modal-body">  
    <input type="text" placeholder="enter first name" id="name" ng-model="firstname" class="form-control" />  
    </div>  
    <div class="modal-footer">  
    <button type="button" class="btn btn-success" ng-click="valSubmit();">Ok</button>  
    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>  
    </div>  
    </div>  
    </div>  
    </div>  
    </div>  
    <div 

Open in new window

0
I have a simple mvc razor view webpage. and javascript.
my question is why below code is not working.
I try to get all of the <input type=text> that has id prefix start with 'cost'.
However, when I take out substring, i can read the entire string.


if (id_name.substring(0,4) == "cost") {
                        alert(id_name);
                    }

@model List<Domain.FleetEventPricing>
@Html.AntiForgeryToken()
@{ int totalcount = 0;}
@foreach (var i in Model)
        {
            totalcount = totalcount + 1;
        <div class="row with-forms">
            <!-- Status -->
            <div class="col-md-8">
                <input type="text" placeholder="@i.eventname" value="@i.eventname" id="eventname_@i.eventId" readonly />
            </div>
            <!-- Type -->
            <div class="col-md-3">
                <input type="text" placeholder="@i.cost" id="cost_@i.eventId"  value="@i.cost">
            </div>
            <div class="col-md-1" style="vertical-align:middle;">
                <a href="#"><i class="fa fa-trash" style="font-size:25px;"></i></a>
            </div>
        </div>           
}
<input type="hidden" value="@totalcount" id="totalcount" />
<div class="col-md-12">
    <a href="#" onclick="UpdateEventCost()" class="button preview">Update Now <i class="fa fa-arrow-circle-right"></i></a>
    <br /><br />
</div>
<script>
        function Validator() {
            return true;
        }
        function UpdateEventCost() {
          

Open in new window

0
I made some changes in my meta file and now my bootstrap datepicker doesn't work.  Here is what I have in the header:
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="GENERATOR" Content="Microsoft Visual Studio 6.0">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="alternate" href="http://gopherstateevents.com" hreflang="en-us" />

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<link rel="shortcut icon" href="/assets/images/g-transparent2-351x345.png" type="image/x-icon">
<link rel="stylesheet" href="/assets/web/assets/mobirise-icons/mobirise-icons.css">
<link rel="stylesheet" href="/assets/tether/tether.min.css">
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap-grid.min.css">
<link rel="stylesheet" href="/assets/bootstrap/css/bootstrap-reboot.min.css">
<link rel="stylesheet" href="/assets/socicon/css/styles.css">
<link rel="stylesheet" href="/assets/dropdown/css/style.css">
<link rel="stylesheet" href="/assets/theme/css/style.css">
<link rel="stylesheet" href="/assets/mobirise/css/mbr-additional.css" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.0/css/bootstrap-datepicker.css">

<script src="/assets/web/assets/jquery/jquery.min.js"></script>
<script 

Open in new window

0
You can see my example here. Download and click on page.html.  https://drive.google.com/file/d/1Kt2CQwvTAdY0uojPf8sf7krVu6sEz61f/view

1. When page loads, I have one row with "And" and the "X" delete.
2. I can click on Add and keep adding divs

What I want to do is:
1. The first row, remove the X
2. When on the last row ( I can have as many rows as I want)...remove And

f1.png
I thought about finding the # of divs that has X and AND. If only 1, hide "X". But that's not going to work.

I think I need to drill down these divs but still not sure how to hide X and AND

f2.png
0
Hi, I have a question of react js:  I need change the value of this.props.sortClick  like below:
if (this.props.sortClick === true)
      {
      this.props.sortClick =false; //How can do it?  can't do this ay, since I can't modify the vaue
          return true;
      }
      else {
          return false;
}
  

    },

Open in new window



Thanks
0
Ajax Success callback doesn't work.
Hello this is my second question i have problem with success callback of my ajax function... it doesn't reload my data table after deleting rows... how can I correct it my code is
<script>
        $(document).on('click', '.delete', function() {
            var that = this;
            swal({
                title: "Are you sure?",
                text: "You will not be able to recover this imaginary file!",
                type: "warning",
                buttons: true,
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "Yes, delete it!",
                closeOnConfirm: false
            }).then(function(yes) {
                if (yes) {
                    var id = $(that).attr("id");
                    $.ajax({
                        url: "delete.php",
                        method: "POST",
                        data: {id: id},
                        success: function (data) {
                        dataTable.ajax.reload();
                        }
                    });
                }
                else {
                    return false;
                }
            })
        });
    </script>

Open in new window

my success code
                        success: function (data) {
                        dataTable.ajax.reload();
                        }

Open in new window

How Can I correct this guys?
0

JavaScript

121K

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.