Posts by Sam • 79,597 points
3,121 posts
-
0
votes2
answers235
viewsA: Borders on each part of the menu
Your CSS is a bit confusing but the main error in your markup is that you are repeating id's, which is incorrect in HTML. An id must be unique on the page. In this case, you are repeating…
-
2
votes2
answers295
viewsA: writeln in Javascript is in disuse or not?
Looking at the specification material Ecmascript 2018 no reference to the function, but in the documentation of the WHATWG.org the function remains active. I believe it is in disuse, because with so…
javascriptanswered Sam 79,597 -
0
votes4
answers114
viewsA: Hide a DIV based on the value of a field
You can call the .change() after the .on(): $(function(){ $('#OrigemAnomalia').on('change', function(){ $(".DivAcidente")[this.value == 'Acidente' ? 'show':'hide'](); }).change(); }); <script…
-
1
votes2
answers162
viewsA: Remove Class from an element two levels above the clicked element
Use .closest() and .prev() to reach the previous div to the parent div where the clicked element is: $(".ver-funcionalidade").on("click", function(){ $(this) // elemento clicado…
-
2
votes2
answers259
viewsA: Trigger Ubmit inside the iframe
You can access the elements inside an iframe using: $("iframe").contents().find("seletor"); Where "seletor" can be an id, class, tag etc., i.e., a normal jQuery selector. In case of submitting the…
-
2
votes2
answers33
viewsA: Number formatting
The .toFixed() only works on data type number. The value in dados[i].quantidade is probably a string number, so it generates the cited error. In this case you must convert the string to number. You…
-
3
votes1
answer87
viewsA: I cannot access value of a JSON object and display it in the div
The main problem is in this row below that you are trying to iterate with for: var nomeObras = jsonObj['members']['name']; Actually the array is just the jsonObj['members'], and the name is a key of…
-
0
votes1
answer67
viewsA: Make mobile like desktop
The class with -xs is no longer used in Bootstrap 4. The correct would be just col-4 for breakpoints smaller than 576px as shown in the table in official documentation of Bootstrap 4. In this case,…
-
2
votes1
answer83
viewsA: How do I convert data from a multi-line Mysql Text field to line-breaking HTML?
Use the function nl2br in the query result. Example: <?=nl2br($row['informacoes'])?> Will add a tag <br /> breaks the lines of the record, resulting in: José, <br /> Maria, <br…
-
1
votes2
answers122
viewsA: Reading XML with TAG, PHP
In XML all tags must be closed. In your case, failed to close tags <ans:cabecalho> and <ans:mensagemTISS>, therefore the mistake. It should be something like this: $arq = '<?xml…
-
2
votes1
answer219
viewsA: Algorithm to set service order priority
You have to take input values inside the function, not outside. This is because when calling the function, the variables to which input values are assigned will always be empty in the page loading,…
-
0
votes2
answers56
viewsA: Problem to run setInterval
There are many problems in your code. First you could not access the function Teste() outside the $(document).ready because the function would have no scope in the other script block. Another…
javascriptanswered Sam 79,597 -
2
votes1
answer119
viewsA: Materializecss, change icon after attaching image in input file
Use a Event Handler which changes the icon (changes the text) which is in the same div of the input file: $(document).on("change", "[name='avariaFoto[]']", function(){ $(this) // input alterado…
-
2
votes2
answers208
viewsA: Dropdown menu superimposing
Before showing the clicked submenu, hide the others before, except what you clicked. You do this by using .not(). It would also be interesting to close the submenus when you close the main menu,…
-
1
votes2
answers719
viewsA: Total sum with multiple values dynamically using jQuery
First you need to create a Event Handler for the price and quantity fields using the event input (this event is triggered in real time whenever you change the fields). Also create a separate…
-
2
votes1
answer71
viewsA: Pass value from a function to value in Javascript input
Just take input by id and change its value: document.getElementById("idade").value = Math.abs(idade.getUTCFullYear() - 1970); Only you have to do it before the return and after the variable idade.…
javascriptanswered Sam 79,597 -
0
votes1
answer40
viewsA: Slick plugin hangs when receiving settings
The problem is that the plugin does not read the values passed as string. For example, you put false in quotes, thus the value is no longer boolean and becomes a string, causing error in the…
javascriptanswered Sam 79,597 -
1
votes3
answers89
viewsA: How to reference only the first occurrences of an A tag using jQuery?
Use the method .prevUntil(), selecting the first div with the class .director_row. It will pick up all the elements between the first div.director_row and the element <b>Genre:</b>: var…
-
2
votes1
answer166
viewsA: Add and Remove Divs Function with PHP and jQuery
As I commented, it does not need (nor does it make sense) to put id’s in everything that is element, or change the Names with different names. The only thing you need to enumerate is the text of…
-
2
votes1
answer34
viewsA: How to use Hover
You must put the :hover in the box class .caixa to change the daughter class .caixa-titulo: evento ↓ .caixa:hover .caixa-titulo{ ↑ ↑ pai filha Behold: <!DOCTYPE html> <html lang="pt-br">…
-
3
votes1
answer57
viewsA: .error() in jQuery is not a funciton
According to the official documentation, the event .error() was considered obsolete as of version 1.8 and removed from version 3.0 of jQuery. Instead of that, use:…
-
0
votes4
answers209
viewsA: Doubts with conditional structure
Besides the problem of using the operator || (or) instead of && (and), where the && means that both conditions must be true, in this case it would be better to use a if else and a…
-
2
votes1
answer35
viewsA: Do not insert duplicate value in gridview
Just condition the insertion of a new entry into the array with if checking whether an object already exists with a key of the same value and whether there is already an object with value "yes" or…
-
1
votes1
answer307
viewsA: Click on the label text, make it appear in the input and edit this label
Create a event handler to capture a click on the Abels by class .li_001 (Labels class) by adding the label text clicked on input#valor and assigning the label clicked on a previously declared…
-
0
votes1
answer43
viewsA: Remove Colorrange from Fusion Chart
You can remove the element by the class that ends with fc-gradient-legend (which is the colorrange div class) after the component has been rendered using the event renderComplete: events:{…
javascriptanswered Sam 79,597 -
1
votes1
answer60
viewsA: Why is <li> centered?
Actually it’s not centered. It’s there because the float: left on the tag img is pulling not just the h1 but also the nav to the right, taking the first li. It is not very recommended to use float:…
-
1
votes1
answer53
viewsA: How to get Dynamic Javascript from another site?
You can use the JSON.parse(), but it is necessary to remove everything that is not object of the string, such as tags <script> and the array delimiters [ and ] (or ];, the semicolon after…
javascriptanswered Sam 79,597 -
2
votes2
answers739
viewsA: Open page in PHP
The basic error is missing the underline between the $ and the GET: would be $_GET instead of $GET. Another error is that you are putting a tag opening sign on <? before closing the tags…
-
0
votes2
answers3933
viewsA: Align the "Nav-item" to the right, leave centered
Put the class w-100 and align-items-center in ul.navbar-nav so that it occupies the entire width of the navbar and allows the elements to be vertically centered, and place the class ml-auto in li…
-
2
votes3
answers181
viewsA: Position a circular image in the center
To center the circle horizontally, as it is a block element (div), simply add the property: margin: 0 auto; The first value 0 represents the margins top/bottom and the second value auto the margins…
-
0
votes1
answer37
viewsA: Error in classlist.toggle
To add classes use .classList.add() instead of .classList.toggle(). This is because the second will add and remove the classes of the elements every time in the loop while in alternation, that is,…
-
1
votes2
answers140
viewsA: Hide one div while the other is visible
A simpler way is by using the event onclick. just capture the click on the button and change a CSS class that hides the element using the native Javascript method .classList.toggle(). Put a id…
-
3
votes1
answer1548
viewsA: How do I place Text inside a Shape made with CSS? Is it possible to place text inside a circle?
There is really no property for this. This is because the box elements (div, span, inputs etc.) are built in square form. With clip-path it is possible to hack using the property shape-outside using…
-
1
votes2
answers67
viewsA: Problems with resubmission of form in the POST method
You can disable the button and change its text with "Sending..." so that the user not only can click again view that the form is being sent: document.addEventListener("DOMContentLoaded", function(){…
-
1
votes2
answers637
viewsA: How to add icons before the placeholder
A nice way is to use an image as Sprite (it can be a PNG with transparent background, a GIF or a JPG with white background). Then just add the image as background input by positioning each Sprite…
-
2
votes1
answer31
viewsA: Show div when scrolling only
First you must place the property display: none in aside so that it already starts hidden. And put .stop() before the effects fade and fadeOut so that when one is fired does not run over the other:…
-
3
votes2
answers476
viewsA: Diagonal edge at the corners of the page
Create a father and daughter div and put a background linear-gradient with two colors in the father div, and in the daughter div you put a white background. The padding in father div will give the…
-
2
votes2
answers137
viewsA: How to treat Timestamp field return via AJAX?
How everything is strings (the value in item.DT_CRIADO_EM and the value of the array’s first position _valor[]), you can pick up the timestamp on item.DT_CRIADO_EM and convert to date. Catch also…
-
1
votes1
answer46
viewsA: Repeat of select
You should empty select before adding new options to avoid repetition. Place destino.innerHTML = ''; after the line destino=window.document.ftaxi.destino;: function funcorigem(){…
javascriptanswered Sam 79,597 -
1
votes1
answer58
viewsA: Expected text is not displayed
I did not understand this whole revolution if the only thing that changes in the text of the created element is the name of the product and the price. No need to create a text node with the product…
-
3
votes5
answers815
viewsA: Check if URL has string
The .indexOf is to take the initial position of an occurrence of a string in another string. That is, when it finds the first occurrence, it returns the initial position of that occurrence, which…
-
2
votes1
answer315
viewsA: CNPJ Mask function for field with dynamic value
Use the method .unmask() before applying the mask again: $cnpj.unmask().text(data[0]['cpf_or_cnpj']); Note that I changed $($cnpj) by just $cnpj because the variable $cnpj is already the jQuery…
-
1
votes1
answer195
viewsA: Capture the Hidden input values that suffered the event in the "change" select with jQuery serialize()
You are only selecting the select. This is because the select that triggered the change is represented by $(this) in: const formDetails_frete = $(this); And then you’re doing:…
-
3
votes1
answer119
viewsA: How to insert data into an array position
Use the method .find() to fetch the object by the key value name and change the value of the key value of the same object: formSerialize.find(x => x.name == 'id_original').value = "valor que vc…
-
0
votes2
answers38
viewsA: Touchscreen Keyboard - Limit the number of characters entered in javascript
One way is to use one ternary operator in the .val(). If the number of characters is less than 5, it will concatenate the current value + the number clicked, otherwise it will keep the 5 numbers…
javascriptanswered Sam 79,597 -
0
votes1
answer362
viewsA: Can I mark a checkbox per button?
If I understand the question correctly, you will have a table with several lines, and each row will have a checkbox, with the same name, which will be checked by clicking the button of the same…
-
1
votes1
answer821
viewsA: Get input value for AJAX
You are sending in AJAX only the value of image in the field data. To send another value just add to the object of data another key by the name of name and the value of the field input#name: data:…
-
2
votes1
answer172
viewsA: Virtual keyboard pick position in input
With .selectionStart (takes the cursor position in the input) and .setSelectionRange() (position the cursor in the input) you can do this. Then just concatenate the characters before the position +…
javascriptanswered Sam 79,597 -
3
votes1
answer110
viewsA: Writing effect in Javascript
Add another setTimeout calling the same function when the forEach reach the last letter of the text. The time of this interval you sum with the 75 * i. For example, if you want to repeat the effect…
-
3
votes2
answers187
viewsA: Make the result of a table appear in AJAX
Simply insert the AJAX Sponse into the div#div1: $('#div1') .html(response) // insere o HTML vindo do AJAX .show(); // exibe a div You don’t need .empty() or .append(), for the .html() already…