Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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

Hi Guys,

I would like to get the property names from a Javascript object to build a table dynamically. Example:

var data = [{
        Name: "xxxx",
        Last: "bbbbb"
                },
{
        Name: "ddddd",
        Last: "sssss"
}]

Now imagine this properties (Name , Last) come in different name from the database so how could I retrieve the property data from the json array with javascript.

Thank.
0
hi all

i got this for my header

.top {
background: white;
width: auto;
height: 92px;
}

Open in new window


how to do the same for a strip at the foot of page, the same boot on foot
regards!
0
Hi Guys/Girls i'm having trouble with an exchange server, I am trying to upgrade to CU17.

Host is Server 2012R2

i have prepared AD via;

setup.exe /PrepareAD /IAcceptExchangeServerLicenseTerms
setup.exe /PrepareSchema /IAcceptExchangeServerLicenseTerms

then once running the setup for CU17 i get through all pre req checks etc, get too around 94% and the process hangs before Exchange will finally tell me upgrade has failed with this error;

Error occurreSystem.Exception: Failure configuring SearchFoundation through installconfig.ps1 - Error occurred while configuring Search Foundation for Exchange.System.TimeoutException: Timed out waiting for Admin node to be up and running

I have googled, until i can no longer google. Only references i see are firewall issues or permissions issue, none of which are a problem for me, firewall is off, and i am using full permissions.

I think the problem has something to do with my Exchange HostControllerService, It will start but stops immediately after, event viewer reports no problems in regards to it.

I Noticed OWA also will not search mail, So sure that these two problems are related, With search issues i normally expect database index state, but all is healthy.

im all out of things to try, was hoping for some advice. Cheers.
0
oh men, i need to improve a plain web page,
Need to add a heder, a sidebar and a footer, please you experts any idea o examples or already done layer for translate my info

regards!
0
I have a js that produces a result , say data.

<script>
some code
gives data
</script>

Now I need to manupulate data in asp
like say

<%response.write left(dataasp,100)%>
 where dataasp=data

Any ideas ?
0
Hi,
I have problem to show Baidu map within this
http://my-friend.co/RegRec2/?id=18&user_abbr=mc2&readonly=y

What to adjust?
0
I have this site: https://goo.gl/iwpDzp

I am having issues with the navigation drop down on touch devices only, IE: Dell Latitude E7250. To be clear, this does not include tablets or mobile devices, this problem only occurs when using these new hybrid laptop/touchscreen devices. When you "touch" an item in the navigation, nothing happens. The drop down navigation will not appear.

Navigation: https://www.dropbox.com/s/qsicl6h9knkixzq/Screenshot%202017-08-09%2017.16.10.png?dl=0
Example of screen: https://www.dropbox.com/s/0z4y7knf9var709/Screenshot%202017-08-09%2017.16.45.png?dl=0

I have searched high and low on how this can be fixed and cannot find a solution. Any help is appreciated.
0
I had this question after viewing Angular - difference between these 2 pagination methods.

I'm following this example (please scroll down pipe/ajax plugin section here http://lorenzofox3.github.io/smart-table-website/)

In the related question above, I want to do this
"From the page number you can calculate from which index your query will start returning data up to your page limit."

I think I have 2 issues. One is how to get the next index and second...I think I call the database every time user clicks on the next page.

I'll go step by step

1. I changed the stored proc to have row_number. Suppose this. I call it with 1 and 50 and get 50 rows.
create procedure usp_test
@start int,
@end int
as
begin
Select * From( Select *,ROW_NUMBER() OVER(ORDER BY Table.Col) row FROM TableName ) R WHERE row BETWEEN @srart AND @end

end

Open in new window


2. Razor has this (just like the Smart table example)

<table class="table" st-pipe="callServer" st-table="mc.displayedCollectionTest">

Open in new window


3. controller.js has this like the example

 $scopr.callServer = function callServer(tableState) {

    ctrl.isLoading = true;

    var pagination = tableState.pagination;

    var start = pagination.start || 0;     // This is NOT the page number, but the index of item in the list that you want to use to display the table.
    var number = pagination.number || 10;  // Number of entries showed per page.

    cContactService.getPage(start, number, tableState).then(function (result) {
      $scope.displayedCollectionTest = result.data;
      tableState.pagination.numberOfPages = result.numberOfPages;//set the number of pages so the pagination can update
      
    });
  };

Open in new window


4. Issue 1: Here, I don't think this is correct. Database keeps getting called but should it? the example has randomsItems as their datasource but not called on each "page" click to go to next page

In ContactService.js


Open in new window

1
Hi you all
some code or already function or something  
for force strong password from the user?

is for an vb.aspx developement
0
Any idea how to fire the onfocus event of the Ajax toolkit HtmlEditorExtender?
I need to show hide the toolbar when I focus  on the editor.
I tried
 $("#HtmlEditorExtender2").focus(function () {
                    alert("Focused");
                });

Open in new window

but it did not work..
0
I have a bug in my simple ASP.Net web application. To reproduce this, you have to Download the below solution.

Code Download

There is a SQL server .bak file which you need to restore. The connection string in web.config is already pointing to this database "Kentico10" which you are going to restore from .bak file.

Once you run the application it loads the default page "TestPage.aspx".

There is a tree view on this page. Initially, the tree view is collapsed for the level one.

If you try to expand any of the nodes in level one, it will hit the code behind file testpage.aspx.cs , RemoveAndAddChildNode function .

I put a break point at the Line number 282

tn.ChildNodes.RemoveAt(nodeIndex);
This line will remove each child nodes of expanded node. and the next line will replace with a new node.

But the real issue is if we remove the child node using the above line. and if you try to expand any node, the node will never expand.it's being stuck there and not moves.

But try to comment the same line

"tn.ChildNodes.RemoveAt(nodeIndex); "
Expansion works.

But for replacing the nodes, first, i need to remove then I need to add.

So, please help me to expand the node without commenting line 282.
0
I am using a zip code API which retrieves results for matching city and state.  Its an ajax request and it works fine as written below, however, I am trying to HIDE the city and state fields until results come back.

I gave a div the ID of "formDiv" and I set the default style="display:none"

In the code below, I want to set style="display:block" but only if results are being returned to the form with AJAX.  I added the line with asterisks and it does not change the style property.  Not sure how to also add that function in addition to the other results. I omitted the remainder of the code to keep it simple, but if I need to do something different on ajax side to trigger the style change when successful, I will post that as well.

Thanks

$(function() {

	var container = $("#example1");
	var errorDiv = container.find("div.text-error");
	
	/** Handle successful response */
	function handleResp(data){

		// Check for error
		if (data.error_msg)

			errorDiv.text(data.error_msg);

		else if ("city" in data){
******************
			function(){
			document.getElementById("formDiv").style.display = "block";
			}
******************			
			// Set city and state
			container.find("input[name='city']").val(data.city);
			container.find("input[name='state']").val(data.state);

		}

	}
}

Open in new window

0
I am working on an AJAX application and I had the basic parts working.  However when I started thourough testing I started receiving HTTP/1.1 414 Request-URI Too Long.  I tried to convert it to use POST instead of GET but it is not working.    I have tried looking for examples online but I have not found one that makes it clear to me

The attached code works if I use:
 if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
         handleupdaterec();
     }
var myParams = "updaterec.php?acctNBR=" + tableID + "&recID=" + recID + "&myXML=" + myXML;
xmlHttp.open("get", myParams , true);
xmlHttp.send(null)


but not if I use:
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        handleupdaterec();
    }
var myParams="acctNBR="+myAcct+"redID="+recID+"&myXML="+myXML2 ;
xmlHttp.open("post", 'trans.txt' , true);    
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.send(myParams);


In all the examples I saw 'trans.txt' was a url or filename.   What does this refer to?   I tried a non-existent file, an empty file and the calling web page.  Do I need to set special permissions on the file?  

I am receiving no error messages in the debugger or in the apache2/error_log.  I walk through the debugger line by line i see it executing xmlHttp.open,  xmlHttp.setRequestHeader and xmlHttp.send(myParams); but nothing happens.   one of the first lines in updaterec.php writes a record to the error log to let me know it got…
0
I have a question already posted about trying to Redirect my app to my Login page after Session_End fires. I have been trying to get around this all day and I was doing some research and found a piece of javascript code that would display a message when the Session timeout interval was complete. I thought I could put this in my Master page Page_Load event and reset the interval everytime its hit, thus restarting the time it would take for the message to display. Im incorrect on this.
What seems to be happening is, when this code gets hit and lets say the interval is 60 seconds. I do another action, lets say 15 seconds later, to cause another Postback and the code to get hit again. I thought that this would restart the interval to another 60 seconds but it wont.  The first call is still in play, meaning after the initial 60 seconds even though I caused another postback, the message would appear. I want the script to somehow reset itself every time it gets hit.
Bottom line is I want to notify the user with an alert that the Session has ended and they will be redirected back to the login screen. This script would be perfect if I can get it to restart or extend the interval every time it gets hit, kinda like with Session. Is it somehow possible for me to cancel the first call and have this one be the only one to run at that point?
I hope this makes sense? I know I write like a caveman.

Here is the code I initially had in a class and would inherit the class on every page…
0
I am looking at some advanced JavaScript and I see variables declared in the following manner.  I would like to know more about it (like the rules surrounding it), but none of my searching has produced anything.

What's this called ??
var var01 = {};
var01.key01 = "ValueA";
var01.key02 = "ValueB";
var01.key03 = "ValueC";
var01.key04 = "ValueD";

Open in new window


Thanks
0
I have a form that I'm using invisible Recaptcha on - and I want to validate a field prior to submission.  This has turned out to be a far bigger pain than anticipated, mostly due to when the ReCaptcha instance would be rendered.  But - using their docs - I've set up:

<html>
<head>
<script>
  function onSubmit(token) {
    alert("Submitting");
    document.getElementById('myform').submit();
  }

  function validate(event) {
    event.preventDefault();
    if (!document.getElementById('field').value) {
      alert("You must add text to the required field");
    } else {
      grecaptcha.execute();
    }
  }

  function onload() {
    var element = document.getElementById('submit');
    element.onclick = validate;
  }
</script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
   <form id="myform" action="hello.php" method="POST">
     Name: (required) <input id="field" name="field">
     <div id='recaptcha' class="g-recaptcha"
          data-sitekey="your_site_key"
          data-callback="onSubmit"
          data-size="invisible"></div>
     <button id='submit'>submit</button>
   </form>
<script>onload();</script>
</body>
</html>

Open in new window


Now, it will verify that the field has been filled in, it will alert me, but it will not "submit" the action?  It stops at that point.

What am I missing?
0
Hi,
How to put short text to chart below?
16t.png
that is from

http://my-friend.co/Test_rec4/Default.aspx?userid=mc23
0
I'm using Smart Table. http://lorenzofox3.github.io/smart-table-website/

Please scroll down to "Client side Pagination" and "pipe/ajax plugin"

In both methods, the database call to get the dataset has to be done upfront...is that correct? What does "pipe/ajax plugin" offer as far as performance that "client side pagination" doesn't offer? I think if both have to get the dataset upfront, there shouldn't be a difference as far as performance but not sure.
0
Hi Experts,

I know I asked this before, but I am still having trouble making a top row stick.  I would like to avoid two <table" tags, as even though I'm using css, if the table data  is too big it messes up the lines.

Here's a simple prototype that I'd like to get working...
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            #divData{
                outline: 1px solid red;
                height: 500px;
                width: 250px;
                position: relative;
                overflow: scroll;
            }
            #header{
               background-color: silver;
            }
        </style>
    </head>
    <body>
        <div id="divData">
            <table>
                <tr id="header">
                    <th>heading</th>
                </tr>
                                <tr>
                    <td>0.</td>
                </tr>
                                <tr>
                    <td>1.</td>
                </tr>
                                <tr>
                    <td>2.</td>
                </tr>
                                <tr>
                    <td>3.</td>
                </tr>
                                <tr>
                    <td>4.</td>
                </tr>
          

Open in new window

0
I was trying to calculate with sub-total, tax, discount, Packing / Delivery Charges & total.,

This Js code works fine without adding / including (discount, Packing / Delivery Charges)

Js working code :
function calculateTotal(){
	subTotal = 0 ; total = 0; 
	$('.totalLinePrice').each(function(){
		if($(this).val() != '' )subTotal += parseFloat( $(this).val() );
	});
	$('#subTotal').val( subTotal.toFixed(2) );
	
	tax = $('#tax').val(); 
	
		
	if(tax != '' && typeof(tax) != "undefined" ){
		taxAmount = subTotal * ( parseFloat(tax) /100 );
		$('#taxAmount').val(taxAmount.toFixed(2));
		total = subTotal + taxAmount;
	}else{
		$('#taxAmount').val(0);
		total = subTotal;
	}
	
	
	
	$('#totalAftertax').val( total.toFixed(2) );
	calculateAmountDue();
		
}

Open in new window

When i add discount, Packing / Delivery Charges functionality it doesn't
function calculateTotal(){
	subTotal = 0 ; total = 0;  
	
	//packing_delivery = 0; discount = 0;
	$('.totalLinePrice').each(function(){
		if($(this).val() != '' )subTotal += parseFloat( $(this).val() );
	});
	$('#subTotal').val( subTotal.toFixed(2) );
	
	var tax = $('#tax').val(); 
	var packing_delivery = $('#invoice_packing_delivery_charges').val(); 
	var discount = $('#discount').val(); 
	
		
	if(tax != '' && typeof(tax) != "undefined" ){
		
		taxAmount = subTotal * ( parseFloat(tax) /100 );
		$('#taxAmount').val(taxAmount.toFixed(2));
//$('#invoice_packing_delivery_charges').val(packing_delivery); // added
	//	$('#discount').val(discount); // added
		
		
		
		total = subTotal + taxAmount + invoice_packing_delivery_charges + discount;
	}else{
		$('#taxAmount').val(0);
		//$('#invoice_packing_delivery_charges').val(0);
		//$('#discount').val(0);
		//total = subTotal;
		total = subTotal + taxAmount + invoice_packing_delivery_charges + discount;
	}
	
	alert(invoice_packing_delivery_charges);
	alert(subTotal);
	alert(taxAmount);
	
	$('#totalAftertax').val( total.toFixed(2) );
	calculateAmountDue();
		
}

Open in new window


The HTML code for this.,

Open in new window

0
Hi everyone,
                      my tsm 6.4  backup is failing with the message: ANS0326E This node has exceeded its maximum number of mount points.


any idea or steps to solve this issue?

Thanks in advance.

Santiago.
0
Hi EE.
Ref Fiddle here
I've been trolling the net for a while but can't find a solution that will allow me to make the owl items within my owl carousel circular without stipulating a pre set item width.
Essentially I need to make whatever the width of the item is also its height.
CSS or JS solutions very welcome..
N
0
I get this error after compiling the whole project to another computer

Here is the masterpage
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <!-- First include jquery js -->
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
    <link href="StyleSheet.css" rel="stylesheet" />
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet"/>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link href="Content/bootstrap.css" rel="stylesheet" />
<!--   End  -->   
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
   <style>
   
       .carousel-inner > 

Open in new window

0
I have a smart table (followed this example)  http://www.marcorpsa.com/ee/t2444.html

and added paging using this example https://www.js-tutorials.com/javascript-tutorial/angularjs-smart-table-example-demos/

Now, I have 20,000 rows and my paging is 150 pages. But, I bring back the entire 20,000 rows upfont...when the page loads, then page.  Page is very slow. I'm wondering if I shouldn't bring back the 20,000 rows all at once.

I'm using a stored proc and the stored proc itself takes about a couple of seconds. It's when I bind the data to the smart table that takes a few mins.
0
var SequenceSum = (function() {
  function SequenceSum() {}

  SequenceSum.showSequence = function(count) {
    var holder = [];
    for ( var i = 0; i <= count; i++){
      holder.push(i);
    }
    var a = holder.reduce(function(a, b){
      return a + b;
    })
    return a;
  };

  return SequenceSum;

})();
console.log(SequenceSum.showSequence(6))

Open in new window

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.