|
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.
|
|
|
|
|
Hi, I need help on this question
"We want to know whether to order a particular candy. We should make an order if the total number in stock (inStock) is less than the weekly average sold (weeklyAverage).
Create a function called shouldWeOrderThisCandy that takes in
the inventory array
a specific type of candy (string)
The function should find the candy in the array that matches the name passed in.
When that candy is found, return true if the number inStock is less than the weeklyAverage. Otherwise return false.
If the array doesn't have any candy with that name, return false
This is what I have so far.
function shouldWeOrderThisCandy(inventory, string) {
for (let i = 0; i < inventory.length; i++) {
if (inventory[i] === string && inStock < weeklyAverage) {
return true;
} else {
return false;
}
}
return false
}
|
|
|
|
|
So what help is it that you need?
|
|
|
|
|
Hi My modal popup has stopped working I think it could be because I have loaded similar scripts but new to this so don't know. These are the scripts that my _layout.cshtml tries to load:
<script src="/Scripts/jquery-1.10.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/css/bootstrap/tabulator_bootstrap.min.css" rel="stylesheet" />
<link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="/Scripts/jquery.signalR-2.1.1.js"></script>
The error I get is:
Uncaught TypeError: jQuery(...).modal is not a function
at Object.success (Create:34323)
at fire (jquery-1.10.2.js:3048)
at Object.fireWith [as resolveWith] (jquery-1.10.2.js:3160)
at done (jquery-1.10.2.js:8235)
at XMLHttpRequest.callback (jquery-1.10.2.js:8778)
|
|
|
|
|
Are you sure that the jQuery UI script is being loaded before the script which tries to create or show the jQuery UI Modal?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|