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

Dear Experts:

The following java script checks the checkbox "My_CheckBox" on my current acrobat form

if (event.target.value!="Off") this.getField("MyCheckBox").checkThisBox(0, true) ;

How is this script to be tweaked if not a checkbox is to be checked but a radio button named 'MyRadioButton' Export Value = "LED_Lights"

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
The code executes just fine on my desktop browser, but the "Meetings" does not show on my mobile device so I am unable to click on anything.https://jsfiddle.net/Spleendrivel/mg3upjqh/
0
Hi guys,

I have been able to implement a sort of password for a javascript package I am using, called jsPsych 5.0. I used a loop function and a survey-text plugin as follows:
 var password = {
      type: 'survey-text',
      questions: [{prompt: "Please enter the password provided to you by email", rows: 3, columns: 40}],
    };

var loop_node_password = {
    timeline: [password],
    loop_function: function(data){
         var Responses = JSON.parse(data[0].responses);
         if (Responses.Q0 == "mypassword"){
              return false;
          }else{
              return true;
              alert("Please enter the correct password")
          }
    }
};

timeline.push(loop_node_password);

Open in new window

 

This worked well.

Now, the problem I have is that var Responses = JSON.parse(data[0].responses); is returning Responses = {"Q0":"mypassword"}. Trying to access it using Responses.Q0 does not seem to work. Any help with this please? I need to access the value of the key Q0, I am not sure how to search for that in internet. I have tried Responses[Q0], Responses["Q0"], nothing works. All I need is to get the value of the "Q0":"mypassword" - i.e. mypassword. Any help please

All the best and thank you,
Dritan
0
Hi,

I am working on this page https://kroweb.dk/gfdev/

I have an automatic  slideshow at the top of the page. It is generally working as it is supposed to, except for the change of slides where the next slide is displayed kind of "hard".
What I am after here is that the change of slides displays like a soft ease out of the actual slide and a simultaneously soft ease in of the next slide.

Anybody who have ideas :)

The actual slideshow code is this:
<style>
* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {vertical-align: middle;}

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  position: relative;
  margin: auto;
}

/* Caption text */
.text {
  display: none;  
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  display: none;  
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
  display: none;  
}

.active {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-dealy: 1000;
  -webkit-animation-duration: 3s;
  -webkit-transition-timing-function: 

Open in new window

0
I'm not js literate, obviously. I'm trying to override the browser default help text (or hints) using the following code but alert(name.value) is returning undefined, and I don't know why.

html
<div class="form__field">
          <label for="full-name" class="sr-only">Full Name</label>
          <input type="text" class="form-help" id="fullName" name="full-name" aria-describedby="nameHelp" placeholder="Full Name" required">
          <div class="help-icon"<span></span></div>
          <div id="nameHelp" class="help-text">Enter your full name. Example: Mary Doe</div>
          <div class="invalid-feedback">Please enter your full name.</div>
        </div>

Open in new window


js
 <script>
      var name = document.getElementById("fullName");
         alert(name.value);
      name.addEventListener("input", function (event) {
        if (name.validity.typeMismatch) {
          name.setCustomValidity("Name must be a minimum of 3 and maximum of 30 characters long");
        } else {
          name.setCustomValidity("something else");
        }
      });
    </script>

Open in new window


Also, how would I package this script as an external function call.
Thanks in advance
0
I bought this template http://www.tattek.sk/minotaur-dash2/#/app/forms/validation
and I'm customizing it.

1. Scroll down to "Input Mask" section.
2. You see there's a "Phone" field. It's a mask for phone number.
3. It uses a directive.
4. I used the same thing in my code but I changed to this
 <input type="text" name="eligcat2" id="eligcat2" input-mask="" mask-options="{'mask': '(###)'}" maxlength="5" class="form-control" ng-model="user.eligcat2" ng-model-options="{ updateOn: 'blur' }" aria-invalid="true" style="">

Open in new window


5. I want the mask to allow both numbers and alpha. As I have mask': '(###)'}, I can only do numbers.

What I tried

I tried replacing ### with /[a-zA-Z0-9 ]/  but when the page comes up, part of that pattern in the filed. Like it's the text of that  field.

This is the directive that came with the template


(function() {
  'use strict';

  angular
    .module('lawApp')
    .directive('inputMask', inputMask);

  /** @ngInject */
  function inputMask() {
    var directive = {
      restrict:'A',
      scope: true,
      link: function (scope, element, attrs) {
        var options;
        if (attrs.inputMask) {
          options = scope.$eval(attrs.inputMask);
        } else if (attrs.maskOptions) {
          options = scope.$eval(attrs.maskOptions);
        }
        angular.element(element).inputmask(options);
      }
    };

    return directive;

  }

})();

Open in new window

0
how to write if else condition  if table is displayed  border "class" should add . and if table is not displayed border  ''"class" should remove.
 This is Sample Code only. 
when i am hidding the table border is displayed i want to hide the border when table is hidden. 
<!DOCTYPE html>
<html>
<head>
	<title></title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
	<style type="text/css">
		.border{
			border:1px solid red;
		}
	</style>

	<script type="text/javascript">
		$(document).ready(function(){
			if ($(table) == display:none) {
				$(table).removeClass("border")
			}
		})
	</script>



</head>
<body>

	<div class="border">
		<table>
			<thead>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>

			</thead>
			<tbody>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				</tr>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				</tr>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				</tr>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				

Open in new window

0
I am on a Linux server (CentOS), and would like to know what would be the best programming language for scripts that offer quizzes/questionnaires (mostly personality tests and IQ tests).?

The scripts would typically offer quizzes/multiple quizzes of 30 questions or more, display reports at the end with analysis and right/wrong answers, and send reports to users' emails.

Users should be able to log in at later dates and view their results again, re-take a quiz, or take more quizzes.

In the past I have had quizzes written in Perl and PHP with MySQL as the database, however now those scripts need to be replaced.

What programming language would be most appropriate for my purposes, in terms of factors such as security, functionality and being on platforms that are constantly being updated and renewed?

Thanks for your help!
0
Given the following HTML snippet, of which the structure cannot change,  when I click on a span, I need to know the parent divs id, the parent divs parent div id and all of the ancestors based on the div ids and data-parent.


<div id="menu">
	<div id="one" class="expanded highlight">One<span></span></div>
	<div id="two" data-parent="one" class="">Two<span></span></div>
	<div id="three" data-parent="two" class="collapsed">Three</div>
	<div id="four" data-parent="two" class="collapsed">Four</div>
	<div id="five" data-parent="two" class="collapsed">Five</div>
	<div id="six" data-parent="two" class="collapsed">Six</div>
	<div id="seven" data-parent="one" class="">Seven<span></span></div>
	<div id="eight" data-parent="seven" class="collapsed">Eight</div>
	<div id="nine" data-parent="seven" class="collapsed">Nine</div>
	<div id="ten" data-parent="seven" class="collapsed">Ten<span></span></div>
	<div id="eleven" data-parent="ten" class="collapsed">Eleven</div>
	<div id="twelve" data-parent="ten" class="collapsed">Twelve<span></span></div>
	<div id="thirteen" data-parent="twelve" class="collapsed">Thirteen<span></span></div>
	<div id="fourteen" data-parent="thirteen" class="collapsed">Fourteen</div>
	<div id="fifteen" data-parent="twelve" class="collapsed">Fifteen</div>
	<div id="sixteen" data-parent="twelve" class="collapsed">Sixteen</div>
	<div id="seventeen" data-parent="ten" class="collapsed">Seventeen</div>
	<div id="eighteen" data-parent="ten" 

Open in new window

0
sir i have a list :that contain some value : after i am geeting node content value: and cheak that node content value contains list value or not:but i am getting exception because list not converted to charsequence : my code is List<String> xx = new ArrayList<String>(); xx.add("Van"); xx.add("Von"); xx.add("Le"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document d = builder.parse(file); d.getDocumentElement().normalize(); String[] s = xx.toArray(new String[xx.size()]); NodeList ndlist = d.getElementsByTagName("personName"); for (int i = 0; i < ndlist.getLength(); i++) { Node node = ndlist.item(i); NodeList nl = node.getChildNodes(); for (int j = 0; j < nl.getLength(); j++) { Node node1 = nl.item(j); if (node1.getNodeName().equals("givenNames")) { Element element = (Element) node1; String str = element.getTextContent().toUpperCase(); if(str.contains(xx))//error list cannot convert to charsequence { //some opration } } }
0
I have a javascript function to expand the grid rows when an image is clicked.

 <script type="text/javascript">
        $("[src*=plus]").live("click", function () {
        $(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
        $(this).attr("src", "images/minus.png");
       
    });
    $("[src*=minus]").live("click", function () {
        $(this).attr("src", "images/plus.png");
        $(this).closest("tr").next().remove();
    });

Open in new window


I need to call this function from code  behind in order to expand the row dynamically. How can I achieve this??
0
Hi EE,

I am trying to make a searchbar on a website, I am trying to create. I can create entries in the DB, connect to it and receive output. However, I want to have a dynamic search bar meaning I want the following:

1. Update the search when I type the next character (first 5-10 entries based on "table-name" or something similar
2. When I click the result, or move the mouse ontop of it, I want to be able to choose the result and displaying it in gridview or something based on which tables I choose in the db.

I am using the following and only that;

Visual Studio 2017
Microsoft SQL
Basic C#
JS

You could possibly do it some other way, but I am using the tools listed above and I hope the answer will reflect that or at least most of them. As a reference, I am trying to mimic the search feature google uses on its search page.

I hope it makes sense. Been trying  to google it, as well as find youtube videos but I am missing the correct "syntax".

Thank you in advance

Thanks Sarah
0
I would like to add a ticket confirmation number to the ticket shown and then email it.

How would I dynamically add some text to the bottom right where it says "ID" ?

Then, save the image, so my server side code can email it? I will be using PHP

Thank you!
0
I'm currently doing a small from which only contains a html5 pages .. index.html.

Currently I am adding the javascript code to the actual page between script tags.

What I want to do is to create an ES6 module and import it to to this index.html page.

But I want to do this without having to use node, angular or react in a project.

What is the easiest ay to do this with my layout?
0
Product I would like to understand how it works buy looking at the content then creating it anew with a different language since it can no longer be purchased.I have a file for a small program called "SQL Grep" it was designed by a company called www.Gatherbirdsoftware.com the product and company seem to no longer be in business. Last I heard was around 2010-2011. The file I have might be helpful with the design of the product I want to make a similar tool in another language. Python & Java. I do not think it was written in either of those languages.

My questions are:
1. Is it legal to look at someone else's code "if I can even open it...?"
2. And determine how the flow of the code works with the developers language. I do this because I am learning to develop now.
3. The intention is to  build my own product to do the same thing with a newer different language?
4. The product is no longer sold and the site down with no response from the owners? I have sincerely tried.

Originally the products on the site were sold to benefit a childrens hospital. I am doing this for a charity as well. If of course I can do this in the way I hope.
Please advise. Product I would like to understand how it works buy looking at the content then creating it anew with a different language since it can no longer be purchased.
0
I am looping through the Json  and searching for elemnets which have part of id="polyiCircle" or "polyLine" to exclude them from loading on canvas. How must I use next  code snippet

canvas.loadFromJSON( element1, function() {    
                canvas.renderAll();
                 }) 

Open in new window

or what other changes must I make in code below  to get the result?
var fromJson;
function getJsonF(){ 
$.ajax({
  method:"POST",
  url: '/wp-content/themes/4/PgetJson.php',
  data:  {
    "getCanvas":1,
    "whichProject":whichProjectToSave,
    },
    datatype: "text",
    success: function(strdate){
   console.log("getJsonF; "+strdate);
  var jsonParse=JSON.parse(strdate);
   
    for (var i = 0; i < jsonParse.objects.length; i++) {
        var element1=jsonParse.objects[i];
        var justIDC =jsonParse.objects[i].id;
           if (justIDC.includes('polycircle')){// do nothing     
         }else{
              if (justIDC.includes('polyline')){// do nothing  }else{
                canvas.loadFromJSON( element1, function() {    
                canvas.renderAll();
                 }) 
              }            
         }
    }
     },
     error: function(error, txtStatus) {
      console.log(txtStatus);
      console.log('error');
    }
 });
}

Open in new window

0
My partner runs thunderbird v52.7.0 and he keeps getting an error: "A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete. Script: chrome://global/content/bindings/browser.xml:237"

He doesn't have chrome installed. How can I troubleshoot this? Thanks!
0
jQuery or CSS to animate a lightening bolt.

I have an SVG that I would like to animate.  I want to fill it from top to bottom, so it is like a lightening bolt.  I know there are ways to use javascript to fill it but I have NO IDEA where to start.

The following is the SVG I would like to fill from top to bottom.
<svg version="1.1" id="bolt_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
                                                                         viewBox="0 0 600 612" style="enable-background:new 0 0 600 612;" xml:space="preserve">
                                                                <style type="text/css">
                                                                    .bolt_st0{opacity:0;fill:#FFFFFF;}
                                                                    .bolt_st1{fill-rule:evenodd;clip-rule:evenodd;fill:#D42229;}
                                                                    .bolt_st2{fill:none;}
                                                                </style>
                                                                <rect x="154.4" y="41" class="bolt_st0" width="276" height="530"/>
                                                                <polygon class="bolt_st1" points="192,569.5 430.2,270.9 321.2,253.1 415.3,41.1 155.2,322.3 263.2,345.6 "/>
                                                                <rect x="154.4" y="41" class="bolt_st2" 

Open in new window

0
Hi

I'm using DataTables to display some tabular data
Within the data I have a code column which I need to filter by

I can Hide the filtered rows using jQuery I'm not certain this is the best approach as it relies on the whole table being visible

I've made a JS fiddle to illustrate what I'm doing

I've simulated the query form by creating some static JSON and hosting in a myjson bin
0
I'm trying to connect to a service outside our firewall but on our servers and I'm getting the following error:

error
Here is the code:

Code
Not sure how I get around this? This is all new to me?

Thanks!
0
hi,

Many web pages contain information that is not stored in the source code for the page, eg pricing info, so it's harder to scrape.

Where is this info stored when loaded to a PC browser, and how can i read it? some kind of cache or cookie? i'm a newbie on the web side.

example Airbnb: https://www.airbnb.co.uk/rooms/.. any room id... ?checkin=20-05-2018&checkout=22-05-2018&guests=2

Background: I'm trying another angle to resolve this other question: https://www.experts-exchange.com/questions/29094633/Web-scrape-macro-VBA.html

Thanks
0
if we select anything in  search box it should display in select box. please tell me how to set this link with Jquery.
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Autocomplete - Default functionality</title>
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <!-- <link rel="stylesheet" href="https:/resources/demos/style.css"> -->
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  } );
  </script>
</head>
<body>
 
<div  style="float: left;">
  <label for="tags">Search box : </label>
  <input id="tags">
</div>

<div style="float: left;">
  <label for="tags">Select box: </label>
  <select >
    <option></option>
    <option>ActionScript</option>
  </select>
</div>
 
 
</body>
</html>

Open in new window

0
Hi guys. I'm trying to perform a post method action in my php and the site that I post to returns "This site require javascript to be enabled". Now the problem is that this is a backend php script that is sending this post method. The site is http://mlungisi.0fees.us

How can I solve this?
0
1. I bought this template http://www.tattek.sk/minotaur-dash2/#/app/dashboard
and I'm customizing it.

2. On the link above, click on the "hamburger" on top. You see how the side menu shrinks and the main content expands
works
3. In my site, the side menu shrinks but the main content doesn't expand

You can see it here:

Site: http://147.75.0.117:88

Login with admin@admin.com / Password321$

doesn't work
4. I checked the Chrome Developer's tool and I see the CSS tag being added

css
5. I also put debug step in the demo site (I have the code locally from Themefoest).. There's a function setSmallNavigation() but  I commented it out and the demo still worked.

I'm not sure what I'm missing.
0
In full desktop size viewing this page https://www.rakaiaisland.co.nz/gallery/ why does the gallery fade to white as I scroll down the page? Note this seems to occur in Chrome but not Firefox.

How can I track down where the fade out is configured or styled so that I can stop it happening?

Thanks!
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.