|
Well there is your answer.
|
|
|
|
|
I have a datepicker which needs to have its date disabled only on button click. below is the code on button click. I actually wanted to use returned data but for now to check I am only using availableDates for blocking.
Please help.
posting.done(function (data) {
var date = new Date();
var temp = data.split(",");
alert(data);
var year = (new Date).getFullYear();
$("#datepicker").datepicker();
var availableDates = ['01-25-2021'];
$("#datepicker").datepicker({
beforeShowDay: function (d) {
var dmy = (d.getMonth() + 1);
if (d.getMonth() < 9)
dmy = "0" + dmy;
dmy += "-";
if (d.getDate() < 10) dmy += "0";
dmy += d.getDate() + "-" + d.getFullYear();
if ($.inArray(dmy, availableDates) != -1) {
return [false];
} else {
return [true];
}
}
});
})
Dhyanga
|
|
|
|
|
Could somebody help me, please?
With if-else condition works fine, but with these always the first block runs. I don't understand why.
let positiveNumber = -1;
positiveNumber > 0;
positiveNumber ? console.log('positive') : console.log('not positive');
|
|
|
|
|
You need to do the following for an if-else equivalent of what you are trying:
let positiveNumber = -1;
positiveNumber > 0 ? console.log('positive') : console.log('not positive');
This should give you back "not positive"
|
|
|
|
|
You are very kind and quick, thank you!
|
|
|
|
|
I have a js fn embedded in an aspx file. I reference a global code behind variable in the script. Works great. I moved the script to a .js file in the same project. OnClientcClick I find the script just fine but the variable is not available. Is it possible to reference or pass by value a variable to an external .js script?
|
|
|
|
|
It's not possible period. What was happening was the compiler was inserting your value into the js file during compile time or execution time.
Javascript executes on the client side and c# on the server. They are completely separate.
But no, I don't think you can do what you did before in a separate js file. And even if you can, my personal opinion is to never do it.
|
|
|
|
|
Thanks for the quick replay. I did do a goggle search half of the hits said you can the other half said no way. I did try a few examples but nothing worked. I don't do much in js but am curious as to why it would be a bad idea if it did work.
|
|
|
|
|
Member 14924607 wrote: why it would be a bad idea if it did work. Because Javascript executes on the client side and C# executes on the server side. The 2 have no relationship to each other. They should not be mixed.
jQuery.ajax() is a very common way to get values from the server that are needed client side.
|
|
|
|
|
|
Hello, I made my first javascript game and I'm hopping to get some help here to fix some problems in the program please.
This is my code: https://codepen.io/mandyq/project/editor/XYndRv
When I load the page, the DrawGameScreen function is not executing and I have to refresh the page once so the DrawGameScreen function to execute. Much appreciated for some help please.
Queenie
|
|
|
|
|
If you want help with some code then you need to show it as part of your question. People here are not going to go to some other website and try to analyse what you have done. Please edit your question and add the details there.
|
|
|
|
|
Thank you for your reply.
My code is a bit too long and I don't know which code snippet to include in here.
Can I close this message? I found the answer from somewhere else.
|
|
|
|
|
Hi, I need help turning this client side script code into pseudocode
var slideIndex,slides,dots,captionText;
function initGallery(){
slideIndex = 0;
slides=document.getElementsByClassName("imageHolder");
slides[slideIndex].style.opacity=1;
captionText=document.querySelector(".captionTextHolder .captionText");
captionText.innerText=slides[slideIndex].querySelector(".captionText").innerText;
if(slides.length<2){
var nextPrevBtns=document.querySelector(".leftArrow,.rightArrow");
nextPrevBtns.style.display="none";
for (i = 0; i < nextPrevBtn.length; i++) {
nextPrevBtn[i].style.display="none";
}
}
dots=[];
var dotsContainer=document.getElementById("dotsContainer"),i;
for (i = 0; i < slides.length; i++) {
var dot=document.createElement("span");
dot.classList.add("dots");
dotsContainer.append(dot);
dot.setAttribute("onclick","moveSlide("+i+")");
dots.push(dot);
}
dots[slideIndex].classList.add("active");
}
initGallery();
function plusSlides(n) {
moveSlide(slideIndex+n);
}
function moveSlide(n){
var i;
var current,next;
var moveSlideAnimClass={
forCurrent:"",
forNext:""
};
var slideTextAnimClass;
if(n>slideIndex) {
if(n >= slides.length){n=0;}
moveSlideAnimClass.forCurrent="moveLeftCurrentSlide";
moveSlideAnimClass.forNext="moveLeftNextSlide";
slideTextAnimClass="slideTextFromTop";
}else if(n<slideIndex){
if(n<0){n=slides.length-1;}
moveSlideAnimClass.forCurrent="moveRightCurrentSlide";
moveSlideAnimClass.forNext="moveRightPrevSlide";
slideTextAnimClass="slideTextFromBottom";
}
if(n!=slideIndex){
next = slides[n];
current=slides[slideIndex];
for (i = 0; i < slides.length; i++) {
slides[i].className = "imageHolder";
slides[i].style.opacity=0;
dots[i].classList.remove("active");
}
current.classList.add(moveSlideAnimClass.forCurrent);
next.classList.add(moveSlideAnimClass.forNext);
dots[n].classList.add("active");
slideIndex=n;
captionText.style.display="none";
captionText.className="captionText "+slideTextAnimClass;
captionText.innerText=slides[n].querySelector(".captionText").innerText;
captionText.style.display="block";
}
}
var timer=null;
function setTimer(){
timer=setInterval(function () {
plusSlides(1) ;
},3000);
}
setTimer();
function playPauseSlides() {
var playPauseBtn=document.getElementById("playPause");
if(timer==null){
setTimer();
playPauseBtn.style.backgroundPositionY="0px"
}else{
clearInterval(timer);
timer=null;
playPauseBtn.style.backgroundPositionY="-33px"
}
}
|
|
|
|
|
|
pseudocode is nothing more than a human description of an algorithm. You don't have to describe every single line of code, just the general idea of what's going on.
BUT! You DO have to understand what the code is doing and why. That part is up to you.
|
|
|
|
|
Post the code here so we can try it/check it for the problem that you say.
Reading the code on the images/screenshots is difficult, and is more difficult to debug it.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Hi All
Could anybody help me to explain this block of code:
if(flakes[i].y>h){
flakes.splice(i,1)
}
in this project:https://jsfiddle.net/duymax/tpr5f0vL/2/
Thanks alot
|
|
|
|
|
Array.prototype.splice() - JavaScript | MDN[^]
If the item at the specified index in the array has fallen off the bottom of the viewport, that array item is deleted.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Dear all
could anybody help me to code JS that:
when i mouseup cursor the ball shall not move follow the cursor.
When i mousedown and mousemove the ball shall follow the cursor.
here my code : https:
thanks alot
|
|
|
|
|
|
hello i copied a project in github have been trying to run it my local computer but its not working every time i run npm install i get this error
npm WARN hms@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
how do i solve this
|
|
|
|
|
You probably need to talk to the owner of the git repository.
|
|
|
|