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 have a html page where in some sections i'm using JavaScript and in other parts jQuery.

In a JavaScription funtion i'm doing stome stuff.

Is there a way to run a jquery selector inside a javaScript function?

See i have this selector:

$("#Textbox1")[0].disabled = true;

What's the equivalent of that in JavaScript?
0
I have a piece of code in this fiddle, which simulates an iphone unlock screen, and i would now like to reverse the direction of dragging to unlock such that users drag from right to left to perform the unlock actions.

and this is the fiddle:
https://jsfiddle.net/h6avtu7p/
0
Can anyone tell me why this is causing an Uncaught SyntaxError: Unexpected token , error

I use this kind of function all the time but with numbers only - of course it relates to text but I just can not work out the correct " or ' to get this information to pass to my js function.

<a class="btn btn-primary btn-lg hidden-print" onclick="recordTB(52584,1,'Preliminary 7 2002',12/11/2017)" role="button"> Print &amp; Record</a>

Open in new window


Thank you
0
I'm looking for a solution and I thought a client side javascript function  will work. This function will assign the text or title value of a tab  to a particular control.
0
I have a label control in my Masterpage and I would like the  text property of tab I click in the child place
assigned to the label in the Masterpage. Please show example.

 <ul class="tabs" id="thistab" runat="server">

                <li class="tab-link current" data-tab="tab-1" id="tab11" data-toggle="tab"><a href="#Person">Personal Info</a></li>

                <li class="tab-link" data-tab="tab-6" id="tab16"><a href="#Info" data-toggle="tab"                <li class="tab-link" data-tab="tab-2" id="tab12"><a href="#Assign" data-toggle="tab" title="Assignment History">Assignment History</a></li>
                <li class="tab-link" data-tab="tab-3" id="tab13"><a href="#Issues" data-toggle="tab" title="Issues">Issues</a>

</ul>

Open in new window

0
Hi, I' need to select a specific node in an xml doc... i have this which gives me everything

For Each xmlNode In objXML.documentElement.selectNodes("Data")

but i need a single node and its related nodes that has a specific value.. please see the xml

for example: I need to select only the Data where Bookcode = NEA-CSOP

Thank you

<DocumentElement>
<Data>
  <BookCode>NEA-CSOP</BookCode>
  <BPSday>3</BPSday>
  <BPSwk>6</BPSwk>
  <BPSmth>8</BPSmth>
  <Trackday>-44.6</Trackday>
  <TrackPnL>0</TrackPnL>
  <WAIVImv>0.239</WAIVImv>
  <WAIVexp>0.252</WAIVexp>
  <x90Day>0.256</x90Day>
</Data>

<Data>
<BookCode>NEA-EA1</BookCode>
<BPSday>18</BPSday>
<BPSwk>39</BPSwk>
<BPSmth>44</BPSmth>
<Trackday>-23.5</Trackday>
<TrackPnL>0</TrackPnL>
<WAIVImv>0.219</WAIVImv>
<WAIVexp>0.217</WAIVexp>
<x90Day>0.256</x90Day>
</Data>

<Data>
<BookCode>NEK-MV4</BookCode>
<BPSday></BPSday>
<BPSwk></BPSwk>
<BPSmth></BPSmth>
<Trackday></Trackday>
<TrackPnL></TrackPnL>
<WAIVImv></WAIVImv>
<WAIVexp></WAIVexp>
<x90Day></x90Day>
</Data>
<DocumentElement>

Open in new window

0
I have a side menu and I click on a link. I want to redirect the user to another page and pass a parameter.

1. In Razor, I do this

 <button ng-click="openForm(row.Id)"  class="btn btn-primary btn-border btn-rounded-20 btn-ef btn-ef-4 btn-ef-4b mb-10">{{row.FormName}}<i class="fa fa-arrow-right"></i></button>

Open in new window


2. In AngularJS controller, I have this
 $scope.openForm = function (formId) {

            //console.log(JSON.stringify(formId))

            //$http({
            //        method: 'POST',
            //        url: '/displayform/index',
            //        data: JSON.stringify(formId),
            //        contentType: "application/json",
            //        dataType: "json"

            //}
               
             

            //    ).then(function () { });

          //  window.open('/displayform/index/' + formId, '_self', false);

            window.location = "/displayform/index/?formId=" + formId; 

        };

Open in new window


3. In C# controller
 // [HttpPost]
        public ActionResult Index(string formId)
        {

            ViewBag.FormId = formId;
            return View();
        }

Open in new window


4. The URL looks like this when the user is redirected
http://localhost:63410/displayform/index/?formId=1

Is there a better way of doing this? I wanted the URL to look like this but couldn't get it working...the passed parameter comes out as null http://localhost:63410/displayform/index/1
0
Hello Experts currently our website requires CAC or PKI to get to login screen.  Is there anyway to capture CAC Id's as users login?  Rather than having 1500 users send us their CAC Id's & manually tied to their account?
0
Hello,

I recently added code from this site (https://www.w3schools.com/howto/howto_css_modal_images.asp). Everything works great except the close function. See page: http://doeringdesign.com/ED/#!/page_AP.

Does anyone have any solutions on how to close this popup? Maybe just have it link to the original page?

Thank you!
0
Below codes is on index.html
and how can i carry the id=search value to http://localhost:5489/Quote/BondInfo?

<form role="form"  class="search-form" method="post">
												<div class="form-group">
													<input type="text"  class="form-control" id="search" placeholder="Get our prices. Enter your email">
													<button onclick="fnNext()" class="btn btn-theme" type="button">
														Submit <i class="fa fa-chevron-right"></i>
													</button>
                                                    <script>
                                                        function fnNext() {

                                                            window.location.replace("http://localhost:5489/Quote/BondInfo");
                                                      }
                                                    </script>
                                                    <br />
                                                   <label style="color:white;" >Your Information is safe & secure</label>
												</div>
											</form>

Open in new window

0
I am hosting an app in Firebase hosting.  When I run it locally on localhost:4200, The .js bundles are loaded into my index.html.  When I build and deploy to firebase hosting, it just gets the index.html file but does not get the sources (the .js bundles) Am I missing a step?
0
I have an HTML form with some checkboxes and a couple of required fields on it.  I need the submit button to check that at least 1 checkbox is checked and the 2 required fields have values.  Right now, clicking submit doesn't do anything on the form.  Does the logic of the function and submit button look correct?

The Function:

<script type="text/javascript" language="javascript">
function validateFormFields() 
    {
		var checkboxes=0;
		
        if (document.getElementsByName('_1_1_2_1') == "")
        {
            alert('Please make a selection before submitting the form');
            return false;
        }
        else if (document.getElementsByName('_1_1_3_1').value == "")
        {
            alert('You must make a selection before form submission');
            return false;
        }
		else if 		
	   	(document.getElementsByName('_1_1_62_1').checked) ||(document.getElementsByName('_1_1_61_1').checked) ||
                (document.getElementsByName('_1_1_60_1').checked) ||(document.getElementsByName('_1_1_59_1').checked) ||
                (document.getElementsByName('_1_1_57_1').checked) ||(document.getElementsByName('_1_1_56_1').checked) ||
                (document.getElementsByName('_1_1_54_1').checked) ||(document.getElementsByName('_1_1_53_1').checked) ||
                (document.getElementsByName('_1_1_52_1').checked) ||(document.getElementsByName('_1_1_51_1').checked) ||
                (document.getElementsByName('_1_1_50_1').checked) 

Open in new window

0
Dear Experts

I have below code, which works perfectly fine. When I mouse over the link, it shows the related picture.

But it works with only one id. I want to work it with class so that I can use it everywhere with the class name.

My main object is that, I want to create a dynamic page with php and use this javascript code so that I can show the related picture when mouse is over the link. I select the picture names from mySql database.

How can I make this below code work with class instead of id? thank you

style code is

<style type="text/css">
#Style {
	position:absolute; 
	visibility:hidden;
	border:solid 1px #CCC;
	padding:5px;
	
}
</style>

Open in new window

my javascript code is
<script language="Javascript">
<!--
function ShowPicture(id,Source) {
if (Source=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (Source=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}
//-->
</script>

Open in new window


at last the div and the link code is

<div id=Style><img src=img/myimage.jpg></div> 
<a href=# onMouseOver=ShowPicture('Style',1) onMouseOut=ShowPicture('Style',0)>$id</a>

Open in new window

0
H. I am following a book that is supposed to show me how to create a solar system in JavaScript. The problem is that none of my objects appear on the screen, no sun, earth or mars. Can anyone please tell me what is wrong with this code or what I am missing?

Code:
******************************************************************

<body></body>
<script src="http://gamingJS.com/Three.js"></script>
<script src="http://gamingJS.com/ChromeFixes.js"></script>
<script>

  // This is where stuff in our game will happen:
  var scene = new THREE.Scene();

  // This is what sees the stuff:
  var aspect_ratio = window.innerWidth / window.innerHeight;
  var camera = new THREE.PerspectiveCamera(75, aspect_ratio, 1, 1e6);
  camera.position.z = -1000;
  scene.add(camera);

  // This will draw what the camera sees onto the screen:
  var renderer = new THREE.WebGLRenderer();
  renderer.setSize(window.innerWidth, window.innerHeight);
  document.body.appendChild(renderer.domElement);

  // ******** START CODING ON THE NEXT LINE ********
document.body.style.backgroundColor = 'black';
var star = new THREE.SphereGeometry(500,28,21);
var surface = new THREE.MeshPhongMaterial({ambient: 0xFFD700, color: 0x0000cd});
var sun = new THREE.Mesh(star,surface);
scene.add(sun);

var ambient = new THREE.AmbientLight(0xffffff);
var sunlight = new THREE.PointLight(0xffffff,5,1000);
sun.add(sunlight);

var surface = new THREE.MeshPhongMaterial({ambient: 0x1a1a1a, color: …
0
Hi Experts,

If anyone can tell me how I can code a JS (or jQuery) event for timeout, let say for 10 minutes if there is no activity to do a self.location = 'timeout.html'

However, when the user click something or types, the timer to go back to 10 minutes.

Thank you
0
As a C# developer, I am used to NHibernate and Entity Framework. What can a Node developer use to bring ORM functionality to Node?

In the past, with Node, I have only used SQL command embedded into the code, then executed. I'm am sure, even then, this was a worst practice.

What is the best practice way, using Node.js, to make use of an ORM?

(I am not sure if I am ready for a JSON database like MongoDB unless it helps you answer this question)

Thanks
0
I am not trained in scripting.  The online reservation system for my website includes a page (attached) with a text field "ArrDate".  I'd like an alert to pop up if someone enters a date which is less than ninety days from the current date.  Please provide instructions, if this is possible.
bf0001.html
0
Hello. I have a checkbox list. I want to make it required.  Meaning I want the user to check at least one box in the list.  None of the required field validators work for me.  I also tried doing a javascript validator but I couldn't get that to work.  This is my checboxlist code:

<asp:CheckBoxList ID="cblEduAssistPlans" runat="server" SelectedIndexChanged="cblEduAssistPlans_SelectedIndexChanged" AutoPostBack="true">
                       <asp:ListItem>Individualized education program (IEP)</asp:ListItem>
                       <asp:ListItem>Individualized Family Service Plan (IFSP)</asp:ListItem>
                       <asp:ListItem>504 Plan</asp:ListItem>
                       <asp:ListItem>Other</asp:ListItem>
                   </asp:CheckBoxList>

Open in new window

0
Hi,

I am using DataTables and it is working nicely.

I would like to locate the Search (Filter) and the Info blocks at the top over the table.
I can do that, but the problem is that they are displayed in two lines, and I would very much like them to display in the same line - one to the left and one to the right over the table.

I use tihs js code:
            $('#tdata').DataTable({searching: true, paging: false, info: true, "dom": '<"top"<if>rt<"clear">', order: []});

Open in new window


and it looks like this:
Sk-rmbillede-2017-11-06-14.38.28.png
0
when click on image which appears like x  it shows the table thead like first name etc  i want to add a div before it  . and add some text with borders using jQuery or javascript
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<title>DataTables example - Column visibility integration</title>
	<link rel="shortcut icon" type="image/png" href="/media/images/favicon.png">
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.datatables.net/rss.xml">
	<link rel="stylesheet" type="text/css" href="/media/css/site-examples.css?_=758e23b3f1a4c34d6c055f5cc10bae7e">
	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/fixedcolumns/3.2.3/css/fixedColumns.dataTables.min.css">
	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
	<style type="text/css" class="init">
	
	/* Ensure that the demo table scrolls */
	th, td { white-space: nowrap; }
	div.dataTables_wrapper {
		width: 800px;
		margin: 0 auto;
	}

	div.ColVis {
		float: left;
	}
	/*.dt-buttons{
		float: right!important;
	}*/

	</style>
	
	
	
	<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.4.js">
	</script>
	<script type="text/javascript" 

Open in new window

0
I am trying to install the following for a new application:
Angular5
Bootstrap4
Firebase and Firestore
Firebase Hosting (probably)
Firebase Auth

I can get everything installed but there are dependency issues.  I think Node.js 9.0.0 does not work with NPM 5.5.1 and the Angular/cli.  Node.js 9 comes with NPM 5.5.1 so I'm not sure what the problem is.  I tried to update my package.json file with v. 5.5.1 from 5.0.0 but that causes even more issues.  I know this is all new but has anyone found a way to work around it?  Different versions?
0
I'm following some tutorials to learn Angular 4. I setup my first project with Angular 4 and Visual Studio 2015 Community edition.

This is one example I followed. Example

I put breakpoints and I couldn't debug the code.

I have to use Visual Studio Code to be able to debug Angular 4 in Visual Studio 2015?
I found these Debug 1

and debug 2
0
I'm using the masked input plugin
http://digitalbush.com/projects/masked-input-plugin/

Example 1

I have this fiddle
http://jsfiddle.net/L8btddb1/

HTML
<input id="date" type="text"></input>

JavaScript
$("#date").mask("99/99/9999");

When I apply the above date format mask on the textbox it works fine.


Example 2

Now I revised example 1 to this. I am basically setting a default value on the texbox.
This is how i need the textbox to be on page load.

http://jsfiddle.net/sh1mtce5/

HTML
<input id="date" type="text" value="11/5/2017"></input>

JavaScript
$("#date").mask("99/99/9999");

The masking is getting set on the textbox but notice how the default value doesn't display on the textbox on page load.

It only works if i set the days to double digits like this:

<input id="date" type="text" value="11/05/2017"></input>

How do I fix example 2,
so regardless whether the textbox value is single digits value="11/5/2017" or double digits value="11/05/2017" it will display on the masked textbox on page load?
0
I'm using jquery, bootstrap, jquery.validate in my asp.net MVC 5 application.
I have seeing various solutions but not sure a good stable solution.

In a textbox the value it contains on page load is a date in this format 11/05/2017

Is there a way to do the following. Wether it's with jquery or JavaScript or bootstrap or validate,

If the value contained in the textbox is anything besides a date display a tooltip that says "please enter a date in this format MM/DD/YYYY"

So if I click in the textbox and , if I delete one digit and the text looks like this 11/05/201  at that point the tooltip already appears. If I type the digit back in like this 11/05/2017 the tooltip disappears.

So the tooltip only appears when the textbox value is anything besides a date in this format MM/DD/YYYY
0
I have the jquery script below. and it is working. however, when I try to parse to html that have two same id name. It does not show the value any more. If I put one iabel name id. it works.

How can I make more than 1 label has value from the local storage codes below?


<script>
        window.onload = function() {
            retrieveData();
            retrieveSingleData();
        };
        function retrieveData() {
            for (var i = 0, len = localStorage.length; i < len; i++) {
                var key = localStorage.key(i);
                var value = localStorage[key];
                 
                if (value == "")
                {
                    value = "Missing";
                }
                $('#' + key).html(value);
                //alert(key + " => " + value);
            }
        }       
         
</script>

<label id="test1"></label>
<label id="test1"></label>

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.