Posts by Sam • 79,597 points
3,121 posts
-
2
votes1
answer105
views -
1
votes1
answer181
viewsA: Applying a :checked on a parent div by clicking on the daughter div
In this structure there is no way to do this. CSS does not access parent elements through a descendant (child element). It would have to use Javascript: let boxes =…
-
2
votes2
answers211
viewsA: Child element exceeding parent element
Apply two CSS properties to the button (class .btn): .btn{ word-break: break-all; white-space: normal; } This will make the text occupy only the space of the button, making line break if necessary.…
-
1
votes1
answer53
viewsA: Why does the text skip to the bottom line?
When applying display: block in the element, it will occupy the entire width of the container, staying in a single row. Block elements tend to occupy the entire line. Applique display: inline…
-
1
votes3
answers654
viewsA: Identify the value of a cell of the clicked line of an html table
The document.getElementsByTagName('tr')[1] will always return the same element because you are catching the according to element on the page containing the tag tr. The document.getElementsByTagName…
-
0
votes1
answer35
viewsA: Add second element to "click" javascript event
The jQuery selector accepts multiple elements, just separate them by a comma: $("seletor1, seletor2, seletor3 etc.")
-
1
votes2
answers241
viewsA: Delete button crashes
When using AJAX, always use the delegated form of events. Instead of using: $(".delete2").click(function(){ Use: $(document).on("click", ".delete2", function(){ The object document is always…
-
0
votes3
answers212
viewsA: How to fill input data in BOOTSTRAP POPOVER
You have to use the modal and Popover events: Modal: shown.bs.modal (when the modal becomes visible) Of the Popover: shown.bs.popover (when the Popover is visible) Using a separate function that…
-
2
votes1
answer247
viewsA: How do I put an Alert with IF in Javascript using Values List
The way I see it, you could use two if...else separated and when entering one of the else's, exit function with return;: if(ESTILO=="P_PARAMETER_1"){ DIV_LOV.style.display="inline"; IFRAME.location…
-
2
votes2
answers382
viewsA: reset variable increment javascript
It doesn’t work because when using .fadeOut() the element is not removed from the page, it just wins display: none and stay hidden. With this, when creating a new element, it will have the same id…
-
3
votes2
answers54
viewsA: Mark Previous Check (Parent) to Node
Searching for the checkbox that is in the same cell by name, using .closest and .find() you can mark, but it does not make sense these id’s with brackets, even because you are repeating them, which…
-
2
votes1
answer60
viewsA: Centralize cards on mobile device
Use the native class .mx-auto in cards: Information about spacing classes can be found on official documentation, in Portuguese. <head> <link rel="stylesheet"…
-
1
votes1
answer52
viewsA: How do I pull strings from the URL and mount a specific array for the Google Maps API?
Use the second argument from forEach which returns the index of the array to mount the new array: places.forEach(function (place, i) { ↑ índice And put the argument (in the case, represented by the…
-
2
votes1
answer61
viewsA: Add input field each time function is called
Instead of concatenating .innerHTML with .innerHTML, would be better to create Divs with .createElement. So you can enter an input in each div keeping what was typed in the ones that were already…
-
1
votes2
answers94
viewsA: Validation of a form with javascript if at least one of the inputs of the table rows was completed before submitting the form?
One way is to check the fields of each row within one for. If you find a field filled in on the line, cancel the for with break and part for next. If no field is filled in on a line, the for will…
javascriptanswered Sam 79,597 -
1
votes2
answers2518
viewsA: Put navbar on the right
Just add the native class ml-auto in ul.navbar-nav: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css"…
-
3
votes2
answers163
viewsA: String replacement in javascript
You will have to use an AJAX to fetch the object inside the JSON where the key CÓDIGO OACI is equal to the value entered in the input. To do this, create a file with the extension .json (example:…
-
2
votes1
answer500
viewsA: How to add ID to the tr that are generated with Datatables?
You can use the Datatable API to pick up any line, don’t need to add id’s to them. See below that I apply a red color on the second line: $(document).ready(function(){ var tabela =…
-
2
votes2
answers59
viewsA: placeholder with the same label name
You need to use Javascript for this. As the attribute for points to the id of input, you can change the placeholder field picking up the text from label where the for of the first is equal to id of…
-
0
votes1
answer43
viewsA: Excluding by button
You have to put AJAX inside the event in order to get the variable id and make the request, since, apparently, this should only occur at the click of the button. And left to put the attribute…
-
3
votes1
answer746
viewsA: How to Dropdown Menu Overlay Div Content
You need to put position: relative in the main div so that the child element that has position: absolute is positioned inside relative to the parent element, otherwise it will be positioned relative…
-
0
votes1
answer761
viewsA: Autocomplete in dynamic input
Change DOMNodeInserted for focus. When the field, whether dynamically created or not, receives focus, it will gain autocomplete: $(document).on('focus','.descri', function(){ // este if verifica se…
-
0
votes1
answer1251
viewsA: Reload or Refresh Datatables
Here’s what you’re gonna do: The PHP code that loads data from the datatables (where it has <?php while (oci_fetch($stid_tables)) { ?>) you will put in a file .php separate and make a include…
-
1
votes1
answer51
viewsA: Json how to present in a table
There are two errors in the code: 1) The array is data.dados and not data: { "dados": [... 2) The argument is item in the $.each returns the array indexes and not the values. The first argument of…
-
3
votes2
answers451
viewsA: Validate only one comma in input type ="text"
You can check if the string contains more than 1 comma with .match(/,/g). If so, you keep only the first and eliminate the others using .substring() to take part of the string and make a replace to…
-
4
votes3
answers65
viewsA: vertical menu with select
Use display: none instead of visibility: hidden. So the additional selects will always be below the main select, and will not need to use margin-top to position them. An element with display: none…
-
1
votes1
answer175
viewsA: Send a variable through the Iframe url
You are using simple quotes to delimit the return of echo. When using single quotes, the variable $codselecionado inside is not processed (see this topic), that is, it will be sent literally: the…
-
1
votes1
answer44
viewsA: Run function 1x per click (Javascript)
When calling the function marcar() you are creating a Event Listener. It will always stay active unless you cancel it. That is, if you cancel it after firing it, and it will only be active again…
-
4
votes1
answer248
viewsA: Write HTML and PHP in the same line
What is happening is that the text returned in <?=$testemunhos[$i]['testemunho']?> is coming with a paragraph, something like that: <p>Lorem ipsum dolor sit amet, consectetur adipiscing…
-
2
votes1
answer122
viewsA: How to change two fields in JS
You’re doing it wrong, putting one event inside another. You’re putting events change within the event input, this will generate conflict. You can make it much simpler by using only one event in the…
-
2
votes2
answers205
viewsA: List Attributes of an HTML Element with JS
With jQuery you can extend the method function .attr() to return all attributes of an element: (function(e){ $.fn.attr = function(){ if(!arguments.length){ if(!this.length) return null; var obj =…
-
1
votes3
answers78
viewsA: Align div with css
I think the flexbox should be the div .preenchidaAutomaticamente, and not the .containerConversa2, because it is the first where the messages will be shown. So you could use align-self to align one…
-
0
votes1
answer217
viewsQ: Why can I cancel the onkeydown event but can’t cancel the onkeyup?
Below I have two fields using the same function. In the first field I use the onkeydown and in the second onkeyup: function eventos(e){ if(isNaN(e.key)){ e.preventDefault(); return; }…
-
1
votes1
answer41
viewsA: Replace values of an object based on Keys
One way to do this is by using replace on Keys values using a loop for: const obj = { "example-url": "http://examples.com", "example2-url": "${example-url}/examples", "example3-url":…
-
1
votes2
answers69
viewsA: Preg Replace to remove awesome font from the texts
The problem in using the DOMDocument() is that it adds "trash" to the result. For example, when removing the tag from the string: $string = 'Texto de teste <i class="fab…
-
0
votes4
answers194
viewsA: Exchange images with Jquery
You want to select the element by attribute data-imagem that contains the value troca_imagem. The method .data() returns a value and not an element, such as the .val(). To select an element by the…
-
1
votes3
answers70
viewsA: When opening a div hide the div anteiror
Use only one function for everyone by passing the id of the respective div in the function. Create two classes in your CSS, one to hide and one to show: .esconde{ display: none; } .mostra{ display:…
-
4
votes2
answers87
viewsA: Select only 24 records per day
Use a subquery with LIMIT 24. Create an alias for date_format(hora,'%d/%m/%Y') and use GROUP BY in that alias to return all dates with the result of SUM(ponto): SELECT date_format(hora,'%d/%m/%Y')…
-
3
votes1
answer430
viewsA: Adding an image to the html body of an email
You have to put the absolute path of the image. Type: src="http://meusite.com/ModelOdyss/Images/image.png" Where in meusite.com you will place the domain of your website. The email client will not…
-
1
votes1
answer69
viewsA: In the menu a li does not occupy the whole area of ul. Cut a piece at the beginning of the menu
Just reset the padding of ul with padding: 0: /* Configurações Globais Inicio */ html, body { box-sizing: border-box; margin: 0px; padding: 0px; } ul { list-style: none; background-color: aqua;…
-
3
votes1
answer71
viewsA: Asynchronous request to return the updated table
You need to assemble the table row and insert into the tbody. The way you’re doing, you’re just inserting the JSON return in string form into the whole table. The selector is incorrect. Instead of…
-
1
votes3
answers270
viewsA: How to open a new html file in the same tab?
Use window.open to open a page in the same tab, in my view, it does not make much sense, if the main function of this method is to just open a new tab. You could use location in the onclick. It…
-
1
votes1
answer59
views -
1
votes1
answer44
viewsA: Problems creating items from a dropdownmenu submenu using Javascript
You are building HTML wrong using .append. When you append an open div, the browser automatically closes the div. For example, on this line: selectAdicionarFormaContato.append($('<div…
-
1
votes2
answers518
viewsA: Disable link and button after clicking
A suggestion, which I think best, to let the user know that there is an action in progress, would not be to remove or hide the page element, but to change its behavior and the text. When clicking on…
-
1
votes1
answer61
viewsA: How to call and print <td> elements of a <table> script?
The problems are that you are using the point . in the names of the classes in the document.getElementsByClassName and also missing the index. For example, instead of:…
-
1
votes1
answer30
viewsA: Change value by text
You can do it this way: function soma(){ var resultado = +form.campo1.value + +form.campo2.value/2 + +form.campo3.value; var texto = 'RUIM'; if(resultado > 100){ texto = "BOM"; }…
javascriptanswered Sam 79,597 -
0
votes3
answers412
viewsA: Card misalignment in bootstrap 4’s smaller resolution size
The problem is these classes .mr-3 that applies a margin-right in some Ivs making them smaller when the screen is on .col-sm- (up to 575px wide). You can use a media query in CSS to reset these…
-
0
votes1
answer75
viewsA: Validation of inputs does not update
There’s an error in the line below: csenha2.setCustomValidity(''); The value of the variable csenha2 is the value of the second field, not the field itself. Even then your validation will still be…
-
1
votes2
answers95
viewsA: Move a div and remove it to release content behind
You can do it this way: First change the position of div.frente of absolute for fixed to avoid the horizontal scrollbar when moving it out of the window, and add the property transition that will…