Posts by Sam • 79,597 points
3,121 posts
-
0
votes5
answers3392
viewsA: One below the other input
You can use a div flexbox in column form and define a width for inputs (generally or individually). In the example below I defined a width 200px for the div where the inputs are. Since the div is a…
-
1
votes1
answer67
viewsA: Centralize content
You are using float: left in spans, so it’s all left. Remove the float: left and add two properties: vertical-align: top; display: inline-block; The first to align the elements vertically, and the…
-
0
votes1
answer85
viewsA: How to save and retrieve multiple returns from an AJAX request in a loop?
As I had commented, Ajax is asynchronous. The code within the for is called but the alert which comes soon after is executed immediately before Ajax gives reply. In this case the correct would be to…
-
2
votes2
answers55
viewsA: Set attributes in a single JS block
Could do using a function, passing as parameters the element, and attributes and values as arrays, and make a for in any of the arrays by setting the attributes: function setAttr(el, atts, vals){…
javascriptanswered Sam 79,597 -
1
votes1
answer116
viewsA: jspadf and canvas, does not screenshot the full modal
This is because the component considers the height of the body to generate the PDF. When opening the modal, the height of the page body is limited to what is seen on the screen. What you need to do…
-
2
votes1
answer39
viewsA: Javascript script is not running
There are many errors in your script. You’re probably not seeing them on the console because the form is being submitted quickly in time for you not to see the errors shown on the console, as the…
-
1
votes1
answer45
views -
0
votes1
answer75
viewsA: error message fields required
Change your class .hide for .d-none (assuming you are using BS4) in the alert div: ↓ <div style="margin: 5px;" id="MsgCadastroErroColmeia" class="alert alert-danger d-none" role="alert">…
-
8
votes1
answer5919
viewsQ: Optimal maximum resolution for displaying content in mobile mode
Taking as an example the Bootstrap 4 grid system whose classes treat the content with breakpoints specific according to the screen width resolution of the device (considering the viewport as…
-
1
votes1
answer41
viewsA: Code works on console, but when I call it in document does not work properly
The problem is that you are wanting to manipulate the contents of the file before it has been read due to it being an asynchronous process. On the console you can do it because you’ve had time to…
-
1
votes2
answers202
viewsA: Disable click while Hide/show effect ends with jQuery
When using the selector $('.items').fadeOut... you will call the fadeOut twice, because there are two elements with the class .items. The point was that the fadeOut occurred only once. For this put…
-
0
votes1
answer23
viewsA: Branch Filter Using Buttons
Dude, you don’t have to repeat so many functions. With only 2 functions you get what you need. Now, do not repeat id’s, it is incorrect in HTML. Otherwise, do not use id names starting with number…
-
1
votes2
answers154
views -
1
votes2
answers391
viewsA: visible or invisible input when selecting checkbox
Change how to hide/show the widget based on whether the checkbox is checked: $("#check").click(function(){ $("#Acompnhante")[this.checked ? "show" : "hide"](); if($(this).val()=="Sim"){…
-
1
votes1
answer38
viewsA: Form insert with checkbox
Use a ternary operator. If checked, the value of check goes with the value of checkbox, if not checked, the check will be empty: 'check' : $("#check").is(":checked") ? $("#check").val() : '',…
-
2
votes1
answer288
viewsA: Point counter and difficulty increase in simple Javascript play
One idea would be to count the burst balls creating a variable that starts from scratch: var estouradas = 0; And put a span on the body that will receive the variable value to print the count:…
javascriptanswered Sam 79,597 -
3
votes2
answers41
viewsA: Error when trying to add class dynamically with classList.add() and classname
First you create the element: let paragrafo = document.createElement('p'); Then you add the class: paragrafo.classList.add('text'); You can’t do both at once. Another way would be: let paragrafo =…
javascriptanswered Sam 79,597 -
0
votes2
answers157
viewsA: Align element items according to class using flexbox
Could put margin-left: auto only in the second element .item and order: 1 in class .right. This will make the class elements .right line up on the right causing the second son .item has an automatic…
-
2
votes1
answer45
viewsA: jQuery code for Typescript
Use the .filter.call() on our list: document.getElementById("enter").addEventListener("click", function () { [].filter.call(document.querySelectorAll("#form-login [required]"), function (e) {…
-
1
votes1
answer61
viewsA: Display preview of the video the user selects by input
Are you using onchange 2 times: one in the attribute calling the function and within the function creating a Event Handler onchange. You don’t need the function, just the Event hanlder that already…
-
1
votes2
answers187
viewsA: When selecting checkbox it selects other checkbox
Your selector is wrong. You should only take care of the checkbox checked ($(this)) and not all. Use .next() to select the checkbox adjacent to the checkbox checked:…
-
0
votes1
answer60
viewsA: AJAX does not respect foreach
Make a recursive function that makes one request after another when the previous one was processed. Create a control variable with value 0. After a request has been processed, increment +1 to that…
-
1
votes1
answer25
viewsA: Replace string by image
Empty the element before making the append with the image. So the element (td) will be empty and after the append will only be the image. Before each tableData.appendChild(gridImage), place…
-
2
votes1
answer358
viewsA: Apply jQuery Datepicker to dynamically added fields
After the .append restart the component with: $(".date").datepicker(); This will apply the plugin to the new fields that have been added. Behold: $(function(){ $(".date").datepicker(); var x = 1;…
-
3
votes1
answer19
viewsA: Converting columns into rows by concatenating the results
Use GROUP_CONCAT: SELECT pedido, GROUP_CONCAT(item SEPARATOR ' - ') as item FROM pedidos Test in Sqlfiddle…
-
3
votes2
answers599
viewsA: Image size in the SVG
First you need to define the dimensions of the SVG area you want. As the figure is represented by a square, suppose you want a star with 100x100 pixels. Then set the width and the height in 100px:…
-
1
votes1
answer386
viewsA: Return modal values to main screen using jQuery
First thing is to put one id in the label that will receive the radio text marked, not to confuse with the other existing label in HTML: <label id="valor_radio"> Valor do Radio Marcado…
-
1
votes1
answer33
viewsA: I would like to search no matter the title accent
Use a function (function tiraAcentos below) which returns the string without the accents (as well as already converts to lowercase). Use the function both in the field value and in the string to be…
-
2
votes3
answers51
viewsA: Modal’s button doesn’t work!
You are just checking the click outside the modal area and the close button. Include another condition in if checking whether the id of the element clicked is equal to "accepted": if(e.target.id ==…
-
1
votes1
answer49
viewsA: Start the site with the hidden filter
Place the property in your CSS to hide the div: #escolha{ display: none; } Your Javascript is poorly built. It does not fit $(document).ready within a function. What you should do is check the width…
-
4
votes1
answer82
viewsA: Returning BD data with PHP and AJAX
Do the following: return JSON to an array in PHP: foreach ($query as $key => $fornecedorNome) { $json[] = $fornecedorNome; } print_r(json_encode($json)); And in Javascript do the parse: var data…
-
4
votes1
answer84
viewsA: How do you put two variables together?
Break the two variables in array by line breaking \n and iterate on one by taking the value of the other by the index: <?php $links = "link1 link2 link3 link4"; $titulo = "titulo1 titulo2 titulo3…
-
1
votes1
answer29
viewsA: How to fill a Dropdownlist from another Dropdownlist
When placing var opt = ""; within the loop .each, the variable will be emptied (and redeclared) every iteration of the object dadosGrid. Put it outside, and inside the loop concatenate the variable…
-
0
votes2
answers119
viewsA: Button background does not change when it is first clicked. (Html5, pure CSS and JS)
Like property .style.backgroundColor initially is empty, meaning that it is red, Just put that condition on the if: if (botao.style.backgroundColor === "red" || !botao.style.backgroundColor) { ↑…
-
4
votes1
answer31
viewsA: Problems Making Echo of a Textarea Notebook
Use PHP_EOL (from PHP 5.0.2) to break the lines, but loop inside the textarea not to repeat it: <textarea id="text" name="text" style="overflow: hidden; word-wrap: break-word; resize: none;…
-
0
votes1
answer21
viewsA: Center the list on the side Nav
You have to take the margins and the padding of ul inside the div #NavL: #NavL ul{ padding: 0; margin: 0; } #geral {width: 100%;background: blue; border:2px solid;height: 5000px} #teste {width:…
-
3
votes2
answers290
viewsA: How to make a circle with a diagonal middle stroke in CSS?
You can also use a pseudo-element ::after, centering it with flexbox and applying a 45 degree rotation: .proibido { width: 150px; /* largura da circunferência */ height: 150px; /* altura da…
-
3
votes1
answer1617
viewsA: Confirm before sending form with Submit input
Change the onclick putting return before the function. With this you will expect a response true or false function. If return true will send the form, if return false, the Submit is canceled:…
-
2
votes1
answer90
viewsA: Moving piece, adds new game board
Empty the div that receives the table before doing the appendChild putting: y.innerHTML = ''; After: var y = document.getElementById("gridOfGame"); In function createGrid.…
-
4
votes4
answers120
viewsA: Simplification of the jQuery code
You can use the function .filter() jQuery: $(document).ready(function () { $("#enter").on("click", function () { $("[required]", $(this).closest("form")).filter(function(i,e){ return…
-
2
votes2
answers48
viewsA: Gif appear above the page
You can include some CSS properties to the element in the code itself: $(document).ready(function () { $('#loading').hide(); $('#btn-substituir').click( function () { $('#loading') .css({ position:…
-
1
votes1
answer86
viewsA: Clear previous request and perform new only with the last element with jQuery
Don’t nest event handlers inside another, because it will accumulate these nested handlers. For example, when placing: $(elemento).click(function(){ $(elemento).change(function(){ } }); Every time…
-
5
votes1
answer60
viewsA: Create layout with`content` responsive
You have to adjust many properties in the CSS to position the section. See that I used some calc() in the width (discounting the width of the sidebar) and height (adjusting to the height of the…
-
2
votes2
answers186
viewsA: How to take an image input and display it in the background-image?
There are two errors in the code: Letter is missing r in .backgoundImage. Seria .backgroundImage. The interpolation of the string with placeholder ${} will only work between the signs of crass:…
-
3
votes1
answer71
viewsA: Doubt about HTML table
Actually the second column is empty, but since it does not have a defined width, it is without size. You can define a width in the CSS for the second cells of each line, for example, 200px, using…
-
1
votes1
answer42
viewsA: Perform redirection by getJSON
You need only return the targeting URL, not a script. Change the array in PHP to return only the desired URL: $Array[] = Array( "sucesso" => "painel.php", ); And in Ajax you redirect this way:…
-
0
votes1
answer135
viewsA: take data from a given line
You can do this by deleting the last column where you have the button. You need to pass the this button to be able to find the row and its columns: function test(botao) { var tableData =…
-
1
votes2
answers90
viewsA: Animation with CSS
Another way is to make a rule of 3 to calculate the animation time and the pause time. Say you want the animation to last 3 seconds and take a break from 6 seconds. Adding the two together gives a…
-
0
votes2
answers329
viewsA: Mask to only allow letters and letters to be inserted with accents
Just a simple .test with a regex and a flag i (of case insensitive, either in upper or lower case): function lettersOnly(evt) { if(!/[a-záéíóúàèìòùãõâêîôûäëïöüç]/i.test(evt.key)) return false; }…
-
1
votes1
answer214
viewsA: How to add checkbox values and send this value to another page through Javascript?
Place the button inside the form so it can submit the form. No need to put type="submit" on the button because he’s already by nature type="submit". Place values in checkboxes. These values will be…