|
|
You didn't include any links ... nor have you attributed the source of these words
How to learn JavaScript in three months - Quora[^]
There is a zero-tolerance to plagiarism on this site so please ensure that you properly attribute the source of any information you post.
|
|
|
|
|
How many ways can you output loop information to the browser?
|
|
|
|
|
As many as you have loops.
|
|
|
|
|
prevent validation of the form if numbe1 <number 2
|
|
|
|
|
Your question itself is an answer, only written in pseudocode.
if(number1 < number2) {
} else {
} The number1 and number2 values you need to take care of, where they are coming from. Perhaps a document.getElementById("number1") , or something like that?
Document.getElementById() - Web APIs | MDN
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hola!
es mi primer mensaje en el foro..no encontré subforo de jquery,pero espero que sea el sitio adecuado
Estoy desarrollando un proyecto con PHP en Zend Framework, y en una vista recojo los datos de nuevo cliente con el típico formulario.
hay que introducir (en textbox) 1º Comunidad y 2º Provincia..la idea es que si el usuario teclea "Galicia" en el siguiente textbox se muestren sus provincias...
el caso es que el primer autocomplete funciona, pero el segundo, no y no se que estoy haciendo mal, no me da error el debuger de Chrome, he probado en Firefox, y tampoco..agradecería algo de ayuda
Dejo un copy paste de codigo..gracias por anticipado
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<!--<link rel="stylesheet" href="/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>
</head>
<script type="text/javascript">
$(document).ready(function(){
var comunidades=[
"Galicia",
"Asturias",
"Cantabria",
"Euskadi",
"Navarra",
"Cataluña",
"Comunidad Valenciana",
"Murcia",
"Andalucia",
"Canarias",
"Baleares"
];
var provingal=[
"La Coruña",
"Lugo",
"Orense",
"Pontevedra"
];
$("#comu").keyup(function(){
$(this).autocomplete({
source:comunidades
});
});
$("#provin").keyup(function(){
var comu=document.getElementById("comu").value;
switch(comu)
{
case"Galicia":
$(this).autocomplete({
source:provingal
});
break;
}
});
});
|
|
|
|
|
Es un sitio en ingles
This is an english site.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
The task
I work with Angular and Chart.js (just started working with both for the first time) and need to import a recordset into Chart.js to be displayed as a multi-axis line chart. At the moment I am displaying some dummy data for visualization which works flawless.
The recordset to be displayed is a record of statistical data stored in a local MS SQL database table. There are three columns that need to be displayed from the table in Chart.js.
1. ExeTimeStamp (in SQL server defined as the following style --> "ODBC canonical date and time with milliseconds." http://www.blackwasp.co.uk/sqldatetimeformats.aspx)
2. LogTimeStamp (same as above ExeTimeStamp style)
3. TaskResult (in SQL server defined as a String, holds thousands of recordsets, each containing 15 pairs of "value" and "label" data)
The challenge
By means of the following tutorial (http://www.tutorialsteacher.com/nodejs/access-sql-server-in-nodejs) I was able to connect to the database and to retrieve the data for all three columns to be displayed in Chrome which results in the following JSON output...
{"recordsets":[[
[{
"ExeTimeStamp":"2018-08-11T08:06:47",
"LogTimeStamp":"2018-08-11T08:07:29",
"TaskResult":[
{"value":"1452","label":"Google readings"},
{"value":"1618","label":"Navigate to 'log on' page"},
{"value":"5467","label":"Log in"},
{"value":"2420","label":"Find user"},
{"value":"1500","label":"Click on 'active cases'"},
{"value":"3084","label":"Click on case"},
{"value":"1350","label":"Click on 'documents'"},
{"value":"652","label":"Click on download PDF icon"},
{"value":"5008","label":"Log in via login client"},
{"value":"1","label":"Wait for down-load/check for PDF in PDF viewer"},
{"value":"1299","label":"Click on extended search"},
{"value":"1267","label":"Input search term"},
{"value":"5004","label":"Execute search},
{"value":"1696","label":"Log out"},
{"value":"30366","label":"Total without google readings"
}]
//...remaining recordsets...
}]],"output":{},"rowsAffected":[20461]}
This data now needs to be mapped to Chart.js so it is possible to read the data into the chart display itself.
Having looked at other suggestions, my approach would be to create a new typescript class looking somewhat like this...
export class livelogs implements OnInit {
constructor() { }
ngOnInit() {
}
exetimestamp: Date;
logtimestamp: Date;
taskresult: string[];
}
...in order to make data available for reading by Chart.js from that class.
However each recordset with the 15 pairs of "value","label" data in TaskResult needs to be accessed one pair at a time and mapped individually to Chart.js so each line (and intersecting point) in the chart gets its own value and label.
Therefore, I am in doubt as to whether my approach is the right one, nor if or how it could be actually made to work.
Can anyone point me into the right direction here?
Thanks in advance for any input.
The chart type from Chart.js which I am using now can be seen here...
http://www.chartjs.org/samples/latest/charts/line/multi-axis.html
Note: If someone might wonder why TaskResult wasn't/isn't separated rather into multiple columns, holding each one pair - as it would be a better solution to the problem - I agree, but have already asked the responsible about this option. Since the statistical information in the future will have to be accessed by many users by means of a customized search option, plus that the same information needs to refresh other more specific graphs at a fixed time-interval, the reasoning is that the server would be taxed to hard with constant requests if more columns had to be accessed and the load therefore too high, which makes this possibility a no-go.
|
|
|
|
|
Hi everybody
When I try to open my website (URL)/login.aspx in chrome, it switches in the bar to (URL)/login and goes to "HTTP Error 404.0 - Not Found" page.
but in IE, it works fine.
any idea about this problem
|
|
|
|
|
i learn test regexp,I want it if the value is correct show "learning javascript" but if the value is wrong then show "learning"
the value is always false
this code
{
var data1 =/learning+\s+html+/g.test(data1)
if (data1==true) {
console.log("learning javascript");
}else {
console.log("learning");
}
}
panggilRegexp("learning javascript")
any solution?
|
|
|
|
|
Alboyz wrote: var data1 =/learning+\s+html+/g.test(data1)
You're trying to use the variable data1 before it has any value assigned to it.
Your regular expression is also slightly off: the + means the previous element can be repeated one or more times, so you'll match "learninggggg". You're also testing for "html" instead of "javascript".
You'll probably was a case-insensitive regex, so that you match "JavaScript" or "Javascript" as well as "javascript".
Assuming you've missed the first line of your function:
function panggilRegexp(input) {
var isMatch = /learning\s+javascript/gi.test(input);
if (isMatch) {
console.log("learning javascript");
}
else {
console.log("learning");
}
}
panggilRegexp("Are you learning JavaScript yet?");
Regular Expressions - JavaScript | MDN[^]
JavaScript RegExp Reference[^]
Regex testing tool[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
|
Hi,
I have a big problem with JS.
I would like to add to my dropzona component a list of files on the server.
I have this code:
<pre lang="Javascript"><div class="row">
<div class="col-12">
<form class="dropzone" id="dpz-multiple-files" action="http://localhost/dropZoneUpload.php"
method="post" enctype="multipart/form-data" style="border:1px solid #000;">
</form>
<br>
<center>
<button id="submit-all" style="height: 40px;"> Upload All the files</button>
</center>
</div>
</div>
function getValueFromJson() {
let res = $.ajax({
url: 'http://localhost/dropZoneUpload.php?parm=1',
type: 'get',
dataType: 'json',
success: function (response) {
return response;
}
})
return res;
}
The php file returns the result:
[{"name":"index.html","size" ,"path":"..\/assets\/uploads\/index.html"},{"name":".DS_Store","size":8196,"path":"..\/assets\/uploads\/.DS_Store"},{"name":"q1.jpg","size":433382,"path":"..\/assets\/uploads\/q1.jpg"},{"name":"bla.jpg","size":193540,"path":"..\/assets\/uploads\/bla.jpg"},{"name":".htaccess","size":106,"path":"..\/assets\/uploads\/.htaccess"}]
In this way I define the truncated JS:
Dropzone.options.dpzMultipleFiles = {
uploadMultiple: true,
paramName: "file",
maxFilesize: 100,
maxFiles: 2,
createImageThumbnails: true,
acceptedFiles: ".png,.jpg,.jpeg",
clickable: true,
thumbnailWidth: 150,
thumbnailHeight: 150,
autoProcessQueue: false,
init: function () {
var submitButton = document.querySelector("#submit-all")
dpzMultipleFiles = this;
submitButton.addEventListener("click", function () {
dpzMultipleFiles.processQueue();
});
this.on('completemultiple', function (file, json) {
$('.sortable').sortable('enable');
});
this.on('success', function (file, json) {
let val = file.accepted;
if (file.accepted == true) {
console.log(json);
$('.main_form').append("<input type='text' name='imgFiles[]' value='" + file.name + "'/>");
}
let val1 = file.name;
});
this.on("addedfile", function (file) {
var removeButton = Dropzone.createElement("<button> Remove file </button>");
var _this = this;
removeButton.addEventListener("click", function (e) {
e.preventDefault();
e.stopPropagation();
_this.removeFile(file);
console.log("kasuje" + file.name);
console.log(file);
});
file.previewElement.appendChild(removeButton);
});
this.on('drop', function (file) {
console.log('File', file);
alert('bb');
});
this.on("maxfilesexceeded", function (file) {
this.removeFile(file);
});
}
};
$(function () {
$(".dropzone").sortable({
items: '.dz-preview',
cursor: 'move',
opacity: 0.5,
containment: '.dropzone',
distance: 20,
tolerance: 'pointer'
});
});
How can I display a list of my files in DropZoneJS (downloaded from PHP)?
I found an example on the Internet:
$(".dropzone").dropzone({
init: function() {
myDropzone = this;
$.ajax({
url: 'upload.php',
type: 'post',
data: {request: 2},
dataType: 'json',
success: function(response){
$.each(response, function(key,value) {
var mockFile = { name: value.name, size: value.size };
myDropzone.emit("addedfile", mockFile);
myDropzone.emit("thumbnail", mockFile, value.path);
myDropzone.emit("complete", mockFile);
});
}
});
}
});
But I do not know how to adapt it in my code.
Can I ask for help?
Does anyone know how to do it?
|
|
|
|
|
i have content page of master page i placed date picker for text when i run visual studio style worked but when i run from IIS style not working
how to slove that
|
|
|
|
|
thepast wrote: how to slove that No idea. I can't see anything you've done. However, it sounds like you did not deploy all of the files. But it could be your code too.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Sure. One time I did it. You can put in home mode and deploy.
|
|
|
|
|
Hi,
I am trying out a few things in JS today and I noticed something strange happening.
console.log(null >= 0); results in true
but both
console.log(null > 0)
and
console.log(null == 0) result in false.
How is this possible?
Thanks for explaining.
|
|
|
|
|
The reason is that an equality check == and comparisons > < >= <= work differently. Comparisons convert null to a number, hence treat it as 0 . That’s why null >= 0 is true and null > 0 is false.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very much, Richard.
|
|
|
|
|
I spent hours trying to figure this out and thought I would post a working sample since I could not find one that was complete.
Plus I'm going out of my way to not use JQuery anymore, and since this is within an Angular V6 component why not try it in TypeScript.
So the concept is to either select a image file using the file input or drop a image file on the target and show the image selected or dropped. Then use the FileReader and extract the Base64 and assign it to the src of the image element target, or you can create a new image element if you choose and assign the new src to it.
Point being to show the user something has happened to satisfy their new for instant gratification and to solve the issue of not wasting time going to the server, doing lots or work and sending it back.
In TypeScript, reader.result can return either a string or ArrayBuffer described as string|ArrayBuffer which was confusing to me because I had to make the TypeScript Lint happy so it would compile.
This would not work and the lint complained that type ArrayBuffer could not be converted to string.
b64Image = reader.result;<br />
dI.setAttribute('src', b64Image);
This would not work either with the same complaint
b64Image = reader.result;<br />
dI.setAttribute('src', b64Image.toString());
This worked without complaint
b64Image = reader.result.toString();<br />
dI.setAttribute('src', b64Image);
Working sample in TypeScript for an Angular 6 component.
9/19/18 16:43 - I got this wrong when I posted it. Had to research it again and add the listener.
Works but really slow setting the b64 hidden text box.
onDrop(event: any) {
let dI = document.getElementById('dropImage'),
b64 = document.getElementById('AvatarB64'),
files = event.target.items || event.dataTransfer.items,
file = files[0].getAsFile(),
reader = new FileReader,
b64Image = '';
this.containerReset();
this.imageFilename = file.name;
event.dataTransfer.dropEffect = 'copy';
if (file) {
this.imageType = file.type;
reader.addEventListener('load', function () {
b64Image = reader.result.toString();
dI.setAttribute('src', b64Image);
b64.setAttribute('value', b64Image);
}, false);
reader.readAsDataURL(file);
};
reader.onerror = (error) => {
console.log('', error);
};
event.preventDefault();
event.stopPropagation();
}
One thing here is the use of arrows, something I need to read up on. I suppose I could try it and see what happens but I need to move on and write the File Button code.
reader.onloadend = function () {
reader.onloadend = () => {
If you have any suggestions feel free to comment on it. Remember this is TypeScript.
Perhaps one day CP will add discussions for TypeScript or really Angular, React and NodeJS. I'm pretty excited about it and will most likely make the move to these technologies.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
modified 19-Sep-18 21:45pm.
|
|
|
|
|
I'm missing something here on matching the file type to the string.
I tried !== and !=
It must be related to the order of if and else if in which I'm not understanding the rule.
Perhaps every thing has to be true and finally false
https://www.tutorialspoint.com/typescript/typescript_if_else_statement.htm
I've checked the heck out of the strings to make sure it can actually match.
Scratching my head on this one. Don't forget this is TypeScript and not JavaScript.
This doesn't work
if (files.length > 1) {
event.dataTransfer.effectAllowed = 'none';
this.containerAlert(1);
console.log('drag canceled for too many files');
return false;
}
else if (fileType.split('/')[1] != 'jpeg' || fileType.split('/')[1] != 'png') {
event.dataTransfer.effectAllowed = 'none';
this.containerAlert(2);
console.log('drag canceled for not being an image file = ' + fileType.split('/')[1]);
return false;
}
else {
this.containerReset();
event.target.style.opacity = '0.4';
}
This works
if (files.length > 1) {
event.dataTransfer.effectAllowed = 'none';
this.containerAlert(1);<br />
console.log('drag canceled for too many files');
return false;
}
else if (fileType.split('/')[1] == 'jpeg' || fileType.split('/')[1] == 'png') {
this.containerReset();
event.target.style.opacity = '0.4';
}
else {
event.dataTransfer.effectAllowed = 'none';
this.containerAlert(2);
console.log('drag canceled for not being an image file = ' + fileType.split('/')[1]);
return false;
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I think the problem is in your logic - in English: "if file type is not jpeg OR file type is not png" always evaluates to true. If the file type is "jpeg", then it can't be "png", so the part after the OR matches. If the file type is "png" then it can't be "jpeg", so the first part matches.
Replace the || with && and you should get the block executing when the file type is not "jpeg" AND not "png".
|
|
|
|
|
Oh your right, that did the trick.
I'm new to TypeScript and thought || would of done the job. Guess it would of failed in JavaScript as well.
This TypeScript is harder to write in.
if (files.length > 1) {
event.dataTransfer.effectAllowed = 'none';
this.containerAlert(1);
console.log('drag canceled for too many files');
return false;
}
else if (!fileType.match('^image/jpeg') && !fileType.match('^image/png')) {
event.dataTransfer.effectAllowed = 'none';
this.containerAlert(2);
console.log('drag canceled for not being an image file = ' + fileType.split('/')[1]);
return false;
}
else {
this.containerReset();
console.log('We have a valid image file')
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|