Posts by Jorge.M • 2,818 points
134 posts
-
2
votes1
answer70
viewsA: Javascript function Locks all input fields
Using the querySelector, you will be applying the rule only to the first element found in the DOM. Grab all elements using the function querySelectorAll that will return an array with all the…
javascriptanswered Jorge.M 2,818 -
2
votes2
answers533
viewsA: Enable next Bootstrap Wizard step if checkbox is checked
I made an example using the Pills of bootstrap. How are you using links, the effect of disabled which is applied to buttons. To achieve this, I set the links without the attribute href and added as…
-
0
votes1
answer119
viewsA: Slidetoggle - Open and Closed Configuration - jQuery
Just do you remove the class from all elements and then add only in the element clicked. In his success, would look like this: success: function (data) { $(response).slideToggle('fast', function ()…
-
1
votes1
answer131
viewsA: CSS customization with jQuery
As the goal is to select only the tag i, in his success you can do so: $('a[data-consult-id]').click(function(){ //use isso para zerar o background dos outros, deixano selecionado apenas o que você…
-
3
votes3
answers490
viewsA: How to use foreach in Javascript associative array
You need to use objects to be included in the array, you can mount them and use the function push() to receive in the array. Would look like this: let myArray = []; myArray.push({'zero': 0})…
-
0
votes2
answers61
viewsA: Remove a class from a tag with more than one class
You wrote removeclass but the class name is removeClass, uppercase "c", and you don’t need to put the class selector when removing. The correct is: $(function(){ var selectRadio =…
-
0
votes1
answer45
viewsA: How to run an IDE with ajax
Just run the function remove() within the success of your AJAX, filtering through tr. As the function is running on the button, and the button is inside the tr, just do it like this: function…
-
0
votes1
answer72
viewsA: Take larger ID and insert Bank
Just select with order by and limit the return to 1 value. Would look like this: SELECT id FROM tabela ORDER BY id DESC LIMIT 1; How are you using PDO, to catch the id would be +- so the result:…
-
2
votes3
answers60
viewsA: Detect parts of a string
If the phrase is always the same as you said, you can do it this way: let phrase = "Definir a altura de cadeira para 500"; //quebra a frase no primeiro "de" let part1 = phrase.split(' de ');…
javascriptanswered Jorge.M 2,818 -
1
votes1
answer42
viewsA: Insert Mysql Database
The error is in that line: $sql_insert = "INSERT FROM fotos (foto_url) VALUES (:TARGET_FILE_NAME)"; There is no INSERT FROM and yes INSERT INTO. Trade that line for that: $sql_insert = "INSERT INTO…
-
0
votes1
answer82
viewsA: Store "do not show again" with localStorage
Simple, first you need to capture in your event click that the div was clicked, could be something like: $(".fechar").click(function(){ $("#mensagem").hide(); //definindo que foi clicado…
-
3
votes3
answers770
views -
0
votes2
answers165
viewsA: How to display/hide a field(input date) from a select field?
Taking into account that: Value 0 = Show input Value 1 = Hide input I did the following example using Vanillajs: function hideShowInput(val) { let input = document.getElementById('date'); if(val ==…
-
1
votes1
answer69
viewsA: How to click link open corresponding panel
To leave the collapse of bootstrap actuated, the class in must be involved in div of the element. You can just do it like this: $(function(){ // check if there is a hash in the url if (…
-
1
votes2
answers301
viewsA: Doubt to use Replace together with Inner Join
The function REPLACE of MySql has the following syntax: REPLACE(str, find_string, replace_with) Parameters: A string The string you want to replace The string that will replace the fetched…
-
1
votes1
answer45
viewsA: Find other select results
First, you will need to identify which valor is being captured in the variable $cidade to then take action. The logic is quite simple: If the value is equal to OUTROS, the select will be mounted…
-
0
votes3
answers6987
viewsA: Format DD-MM-YYYY string jquery date
Another way would be using the function split() javascript: let data = "2016-12-08 00:00:00.0"; let split = data.split(' '); //separa a data da hora let formmated = split[0].split('-');…
-
1
votes2
answers983
viewsA: Leave Input next to Label
Just declare the class form-inline on your form. Upshot: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"…
-
3
votes1
answer437
viewsA: validate all form fields with Javascript
You can take the elements of the kind radio and checkbox as follows: 1 - All elements must have the attribute name (in this example captured the same by this attribute) 2 - In the capture, we need…
-
2
votes2
answers395
viewsA: Know if at least one checkbox is selected within an array of the Laravel
I made a version using vanillaJS, just pick up and adapt to your code. All the code is commented, if there are still doubts, leave in the comments. //capturando todos os checkboxs checks =…
-
15
votes1
answer7037
viewsA: When to use querySelector instead of getElementById?
In addition to the performance involved (getElementById is a bit more performatic, I will quote some tests below) we can consider: Queryselector The advantage of its use, as opposed to…
javascriptanswered Jorge.M 2,818 -
1
votes1
answer103
viewsA: Combox check/clear checkbox
I created a functional example for this. Some considerations are needed: 1- In your field select, added a worthless option to be able to identify the event of change, if it had not been set, the…
-
2
votes2
answers1161
viewsA: Show button when checking checkbox
You are calling the function at all checkbox and just toggle the state of the button each click at the checkpoints. I performed some readjustments in your code, follow some of them: 1-I placed a…
-
2
votes2
answers134
viewsA: Disable Scroll for a period of time
You just need to pass a function callback in the case setTimeout that will be fired X time after your scroll hide. I left the code commented and set 2 seconds for the function to be called in order…
javascriptanswered Jorge.M 2,818 -
5
votes2
answers913
viewsA: How to change the selected text color and background with the mouse?
You get this effect using the pseudo-element ::selection. The pseudo-element has support for most browsers including IE-9, but on today’s date 24/10/18 there is no support for the IOS Safari nor for…
-
2
votes2
answers47
viewsA: Place event button to access page
The problem is that you are trying to open a new window of navegador without passing a URL as a parameter. The way you are using it is not possible because the function will not understand the…
javascriptanswered Jorge.M 2,818 -
2
votes1
answer41
viewsA: Optimization of php code (NF key generation)
The question is, is the substr really the equivalent of the right or is there a function that can replace this method? Yes, the function substr of php has the same functionality as the function…
-
6
votes1
answer419
viewsQ: How to rename a Constraint in mysql?
I created a Constraint primary key in my table as follows: CONSTRAINT PK_user_type PRIMARY KEY(id) But now I need to rename it: CONSTRAINT PK_type PRIMARY KEY(id) Based on this, I have the following…
-
0
votes2
answers203
viewsA: Generic function js
To make a function dynamic, you need to use the values passed by reference within its function. It would look like this: function calcular(valor, quantidade, qt_devolvida, resultado) { var_quant =…
-
5
votes1
answer40
viewsA: .val does not work on Ubmit button
We have some points to consider: 1- Use of the function val() is not feasible in this case because its button does not have the attribute value. 2- Using text() you will manage to change the texto…
-
0
votes1
answer133
viewsA: How to create a function for my IF with Class Public Function?
If you need to perform the same check several times, you can create a function that returns true if the number of rows found in the table is greater than 0, if not, nothing will be done. Could…
-
1
votes3
answers873
viewsA: Key modal Event
You can use a input of the kind hidden to be the acionador of the event. That way, just capture the key that was pressed and trigger the event trigger('click') to open the modal. Here contains a…
-
0
votes3
answers37
viewsA: Improving jquery code
Make a função you receive as a parameter: 1- The elemento to be modified. 2 - The class of elemento. Would look like this: function ModificaElemento(element, classe) { $(element).hover( function(){…
-
1
votes2
answers90
viewsA: Onmousemove event with jquery
Like quoted by Anderson, it would be necessary a response that is flexible to the number of tooltips that you have on the page. Based on that link, created this example that will apply the effect to…
-
2
votes2
answers139
viewsA: Print Checkbox with Jquery
How are you using bootstrap, you can use a class that esconde the elements it has at the time of printing. In the version 3.3.7 bootstrap, the class is : .hidden-print In the version 4.1 is called:…
-
1
votes1
answer30
viewsA: Redeem value of object
You can use the function current that points to the index corrente of array, in that case the index 0. Would look like this: current($obj); Alternatively, you can convert to array: $xml =…
-
3
votes2
answers308
viewsA: Increment numbers to ID name
Simple, first you will need to put the inputs in a div, then create a counter variable, I declared it as cont, after, capture the event click, and giving a append of the element in div maid. To…
-
1
votes1
answer258
viewsA: In jquery write a different link in a href
Whereas only the class element tour-360 will be the target, you can do something like this: let element = $('.tour-360'), //pega o elemento pela classe idElement = element.attr("id"); //pega o id do…
-
0
votes3
answers286
viewsA: To create alphabetical list in PHP according to variable number
First you have to have one array with all letters, example: $letras = ['a', 'b', 'c', 'd']; After that, just perform a for to walk the array letter. Would look like this: <?php $alternativas = 2;…
-
2
votes1
answer46
viewsA: How to create records in the MYSQL table according to the value of the $nregistros PHP variable
For this feat, a simple for can solve. Try something like : <?php $nregistros = 4; for($n = 1; $n <= $nregistros; $n++) { echo "INSERT INTO formularios SET campo = $n; "; } ?> In place of…
-
8
votes1
answer201
viewsQ: Element removal with Javascript
Remove an element using Jquery is the simplest and most objective thing there is, first you capture the element and then remove it: $('#elemento').remove(); I arrived in a situation where I need to…
-
1
votes1
answer51
viewsA: Add access level to this php code
Yes, in that case a if would suffice. Would look like this: <?PHP include('config.php'); # Validar os dados do usuário function anti_sql_injection($string) { include('config.php'); $string =…
-
2
votes3
answers56
viewsA: Use prepare statement at a constant value?
Prepared Statement In short: you will be preparandoyour query protected to prevent attacks such as sql Injection and will also gain more performance in the execution of the consultation. We must…
-
1
votes3
answers232
viewsA: Convert Date to date field
If it does not exceed the year 2000 (much more, rs), da to do so: let str = document.getElementById('dataum').value; //pega o valor let split = str.split('/').reverse(); // quebra o valor entre os…
-
3
votes3
answers1856
viewsA: How do I make the logo disappear when I roll the page?
1: You did not inform which version of bootstrap are using. 2: You did not inform if you have already managed to leave the fixed menu. With the absence of this information, I made an example using…
-
3
votes2
answers53
viewsA: Run icon "Arrow" with JS
Note that in this line you are applying the effect on all elements that have the class rodar: $('.rodar').toggleClass('rodado'); To catch only the element that was clicked, use the $(this).…
-
2
votes0
answers21
viewsQ: Classes named with emoji characters
I was sailing in the web and suddenly I’m faced with it: Yes, it is a "named" class with emoji characters. I was curious and decided to perform some tests to see how it worked, after all, it’s not…
-
1
votes2
answers1122
viewsA: Bootstrap 3 - dropdown-toggle - Changing menu with it open is possible?
You can accomplish this by using :hover in the parent element .dropdown and changing the child element display .dropdown-menu for block. See the example below: .dropdown:hover>.dropdown-menu {…
-
1
votes1
answer19
viewsA: Information exceeds the display location
As I mentioned in the comment above, you are putting a very extensive table for your size box. Use overflow in your box position_box to create a scroll bar when the table size exceeds the box size.…
-
0
votes2
answers72
viewsA: Validation of HTML variable
What happens is you’re mixing code backend with javascript. A solution would be forçar this variable that comes from the backend be transformed into a variable javascript. Put that line on script…