Questions tagged as 'javascript'

1
answer

Replace if loop is empty

Well, I've got a question because I was kind of "stuck" without knowing how to do it. I have the following code: <? foreach($data as $index => $row) { $className = $index % 2 == 0 ? "class" : "class-1" ?> <form action="" name=...
asked by 24.04.2015 / 19:18
4
answers

Html DIV ID defined with echo

I have a problem that I can not figure out, I can not understand why the ID of the DIV does not get the value coming from php, using the value of the constant $i , it always receives the last value of the loop. the proposal is to show / hi...
asked by 20.04.2015 / 16:04
1
answer

Check if more site flaps X is open

Is it possible to check if my site is open more than once in the user's browser? My site requires that only one tab be used to avoid communication error, so I need to alert the user when it opens more than one tab on my site, is there a possi...
asked by 24.04.2015 / 05:31
2
answers

what is the simplest way to print an indented text in javascript for html?

How can you print this in an easier way? public static void swap(int[] list, int i, int j) { /* This method simply takes an array and swaps its values at index i and j */ int temp = list[i];...
asked by 19.04.2015 / 23:20
2
answers

Change color of a div using JS

I'm trying to make a div element change background color when selecting the color of my input using Js. I'm not getting anyone to help me? <style> .corExemplo { width: 150px; height: 150px; border-radius: 50%;...
asked by 29.08.2016 / 23:55
1
answer

Online Calculator Applying Fine and Discount

In my code below it makes a sum between fields per line. What I am not able to do, is when clicking a checkbox it realizes the percentage discount and in the other checkbox add a fine in percentage. below is the image as it is today As I do not...
asked by 28.08.2016 / 18:03
1
answer

How to create a new img tag with jQuery?

I would like to change c:\imagem.jpg according to what was selected in <option id="selecao" value="01">c:\imagem.jpg</option> . Here is the code: <DOCTYPE html> <html> <head> <script t...
asked by 15.04.2015 / 04:56
1
answer

Wait for pending executions to finish to proceed, JavaScript

This is the most practical example I found .. is an example where the server sends 2 messages (or more) followed and at the same time, it does not check if there is something running, in case if it should have wait until the end to send the new...
asked by 04.04.2015 / 16:17
1
answer

Character count inside distinct paragraphs (jQuery)

How to use jQuery to do the sum of characters in different paragraphs? Example: <div id="test"> <p>Lorem Ipsum</p> <p>Lorem Ipsum</p> </div> Obs. Can not add id and class to <p...
asked by 09.04.2015 / 16:28
1
answer

Execution order is not followed

I'm using this library to run IndexedDB functions more easily: Dexie But the code does not follow the order of execution in any way and this causes my script to not work. Example This code is just an example to show that it does...
asked by 03.04.2015 / 02:40