So I need to have an image alternatively appear and disappear every 2 seconds, I’ve been trying using javascript and I’ve gotten stuck, I feel like it’s something so simple but i can’t work it out, any help is appreciated. HTML JAVASCRIPT Answer You need to use callback functions in yo…
Tag: javascript
Razor MVC Populating Javascript array with Model Array
I’m trying to load a JavaScript array with an array from my model. Its seems to me that this should be possible. Neither of the below ways work. Cannot create a JavaScript loop and increment through Model Array with JavaScript variable Cannot create a Razor loop, JavaScript is out of scope I can get it …
Java Server Socket transfer String to web socket
My goal is to set up a connection between a Java Server Socket and a browser (using web sockets). So far, the connection works, but my data streams do not. I would like to send a String from the server socket to the web socket. The problems are the input and output streams. The web socket sends “zustimm…
Javascript: percentage difference between two values
I am using the following javascript code to display the difference in percentage between two values. Which gives: 6.855069696391064 Then The problem is: If value B is higher than value A then i get a NaN, for instance; How can I overcome this issue? I thought about using Math.abs() Any suggestions? Answer I t…
How do I pass variables and data from PHP to JavaScript?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. I have a variable in PHP, and I need its value in my JavaScript code. How can I get my variable from PHP to JavaSc…
Reset variable when variable is 0 [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 8 y…
Node.js synchronously loop or iterate over asynchronous statements
I want to do a for each loop but have it run synchronously. Each iteration of the loop will do an http.get call and that will return json for it to insert the values into a database. The problem is that the for loop runs asynchronously and that causes all of the http.gets to all run at once and my
Check if my website is open in another tab
I want to check with JavaScript if the user has already opened my website in another tab in their browser. It seems I cannot do that with pagevisibility… The only way I see is to use WebSocket based on a session cookie, and check if the client has more than one socket. But by this way, from current tab,…
Javascript: cancel or let an event continue?
My scenario deals with Kendo UI, but I think it probably applies to JavaScript generally, hence the JavaScript tag. I have a Kendo scheduler with the edit event option set to functionA. In functionA, I create a Kendo window (basically a modal) that asks the user a question; in one case the edit event should c…
Socket.io – listen events in separate files in node.js
For example my idea is: File1.js File2.js This code is for a node server, will I have problems with this code? Answer Nope, just use the same “io” object. File1.js File2.js app.js index.html