Posts by JuniorNunes • 4,886 points
146 posts
-
4
votes1
answer630
viewsA: Replace Javascript (How It Works?)
You can use a regex: zipCodeValue = zipCodeValue.replace(/[\-_]/g,""); anything that is dash or underline it will remove. The bars define the beginning and the end of the regex, the brackets define…
javascriptanswered JuniorNunes 4,886 -
2
votes1
answer466
viewsA: How to apply html to text found in javascript?
This code will help you: var reservado = ['insert', 'update']; var regex = new RegExp("([\"'][^\"']+[\"']|" + reservado.join('|') + ")", 'gi'); $('.texto').each(function(i, el) { var texto =…
-
5
votes2
answers4673
viewsA: Hide/Show when checkbox is checked or unchecked
You can do it like this: $('[name="check"]').change(function() { $('[name="op1"]').toggle(200); }); <script…
-
1
votes1
answer2381
viewsA: Sort a column of a table in alphabetical order
This example is working, but I had to make some changes to your code, come on: 1 - Delete the tr emptiness within your tbody 2 - Change your variable table: var table =…
-
1
votes1
answer310
viewsA: Automating a function each JS/Jquery
See if this will work: $('.tab-pane').each(function(index, el) { var id = $(el).prop('id'); $(el).owlCarousel({ loop:true, nav:true, items:1, dots: true });…
-
4
votes3
answers2196
viewsA: Check that the values of an array are all the same PHP?
You can do it with a loop, like this: $arr = ['aaa', 'aaa', 'aaa']; $status = true; foreach($arr as $value) { if($arr[0] != $value) { $status = false; break; } } The variable $status begins as true…
-
5
votes1
answer56
viewsA: Modify Array() HTML form result
Change the structure of your HTML to: <table class="table table-bordered"> <tr> <th width="50" class="text-center">#</th> <th>Item do Pacote</th>…
-
3
votes2
answers1084
viewsA: Maximum limit Google Maps bookmarks
From the looks of it the Google API limits markups when trying to do several at a time. You’ll have to put a delay between each call of the addMarker function, you can take advantage of your loop to…
-
0
votes3
answers507
viewsA: Transform date format DD/MM/YY into MM/DD/YY into Shell Script
A different way to do it is by using the sed: echo "31/12/1970" | sed -r 's/(.*)\/(.*)\/(.*)/\2\/\1\/\3/g'
-
1
votes1
answer80
viewsA: How do I have at most one selected leader in all selects?
I believe that’s what you want: $("select").on("change", function() { var self = $(this); if($.inArray('1', self.val()) != -1) { self.find('[value!="1"]').prop('selected', false).prop('disabled',…
-
2
votes3
answers512
viewsA: Add option inside optgroup
With pure javascript you can do so: addOption = function(optGroup, text, value) { var optGroup = document.querySelector(optGroup); var option = document.createElement("option"); option.value =…
javascriptanswered JuniorNunes 4,886 -
3
votes1
answer96
viewsA: Pure Javascript Drag n Drop
Try this: In drag init you put like this: function drag_init(elem) { selected = elem; y_elem = y_pos - selected.closest('ul').offsetTop; } And the document.getElementClassName you replaced by:…
-
1
votes1
answer75
viewsA: Map all Divs values and perform a mathematical operation
Put your code in an element loop that you want, like this: function calculaParcelaHome(){ $('.product-price').each(function() { var regex = /\d+,\d+/g; var texto = $(this).text(); // pega o conteúdo…
-
2
votes1
answer49
viewsA: Delete options inside optgroup
You can do so to erase everything (including the optgroup) document.querySelector('optgroup[label="opt2"]').remove(); <select name="testSelect"> <optgroup label="opt1"> <option…
javascriptanswered JuniorNunes 4,886 -
2
votes1
answer51
viewsA: Redirecting data from one form to another page
You can access by: $_POST['nome-do-campo'] If your form has with the GET method you use the: $_GET['nome-do-campo'] To fill the textarea you can do so: <textarea><?php echo…
phpanswered JuniorNunes 4,886 -
2
votes6
answers906
viewsA: Convert text from div to number
You can do it like this: var price = document.getElementById('our_price_display'); var formattedPrice = price.innerHTML.replace(/[^\d,]/g, ''); console.log("Valor formatado:", formattedPrice);…
-
0
votes2
answers87
viewsA: How to not load the page by clicking on the select option?
You can do it like this: document.getElementById('filtro').addEventListener('change', function() { if(this.value != 'nAtualiza') { console.log('submit'); this.form.submit(); } }); <form>…
-
1
votes1
answer1487
viewsA: Return select field value in Laravel
I imagine what you’re looking for is this: <div class="form-group"> <label>Tipo de imóvel</label> <select name="tipo_id" class="form-control"> <option…
-
1
votes2
answers1834
viewsA: Select option when clicking button
You can do it like this: $('.botoes_action button').click(function() { $('#pacote').val($(this).data('quantidade')); }); <script…
-
2
votes1
answer397
viewsA: NMAP result using PHP - how to show the NMAP result in a table in the browser?
You can do it like this: $saida = shell_exec('nmap -P0 localhost'); $vetorLinhas = explode("\n", $saida); $start = array_keys(preg_grep('/^PORT/', $vetorLinhas))[0]; $data =…
-
2
votes2
answers82
viewsA: Validating Jquery Price Format Output Money
In PHP you can use a regex to validate the data: $valid = preg_match('/^(\d{1,3}\.)*?(\d{1,3}),\d{2}$/','99.999,99'); The variable $valid will store the boolean value that will inform you if the…
phpanswered JuniorNunes 4,886 -
3
votes4
answers3391
viewsA: Perform Jquery percentage calculation
You can do so without jquery: document.getElementById('percentual').onkeyup = function() { var valor = parseFloat(document.getElementById('valor').value); document.getElementById('resultado').value…
-
5
votes2
answers689
viewsA: Do not send via POST elements within div "display None"
As @Sergio said, you can disable the fields you don’t want to send, follow the javascript code: $(document).ready(function() { $('form').submit(function() { $(this).find('div:hidden…
-
2
votes2
answers2165
viewsA: Mac Address validation algorithm
Good, according to the website you put the MAC standard can be: 6 hexadecimal groups separated by hyphene (-), Ex. 01-23-45-67-89-ab 6 groups of 2 hexadecimals separated by two points (:), Ex.…
-
0
votes1
answer287
viewsA: Add and remove content using javascript
See if that helps you: $('#choose-list li').click(function() { var selectedList = $(this).data('list'); $('[id^="list"]').hide(); $('#list-' + selectedList).show(); }); ul li { display: inline; }…
-
1
votes1
answer293
viewsA: Trigger ~ HTML5 Download Attribute
You can do the following between the tags a you can put the text inside a span with an identifier (in case I put the download class) and use the code to click from one to one, the problem is that…
-
6
votes2
answers1774
viewsA: Read txt and generate a new with ; at the end of each line
If you have separating names by line break you can use this here: $file = fopen('./file.txt','r'); $document = fread($file, filesize('./file.txt')); $formatedDocument = str_replace("\n", '; ',…
-
1
votes1
answer20
viewsA: Duration of the Notification
According to the documentation you should use the property as an option requireInteraction, you will receive a boolean value. var detalhe = { body: msg, icon: 'icone.png', requireInteraction: true…
-
1
votes3
answers528
viewsA: Function that returns the position of the smallest number in a vector
You can use the Math.min.apply to find the lowest value of your array: var numbers = [1, 5, 0.5, 0.8, 10]; var min = Math.min.apply(null, numbers); console.log(min); And to return the position, you…
-
3
votes5
answers3011
viewsA: How to run a PHP function multiple times?
You can do it like this: while(true) { retornaTemperatura(); sleep(2); }
phpanswered JuniorNunes 4,886 -
1
votes3
answers619
viewsA: Urls array - Next button
You can do it like this: HTML: <iframe id="displayURL" src="www.1.com.br" width='100%' height='100%'></iframe> <button id="changeURL">Próximo</button> Javascript: var urls =…
-
3
votes2
answers291
viewsA: Problems recovering a json object
The problem is with SSL, add this in your settings array to bypass the check: CURLOPT_SSL_VERIFYPEER => false,
phpanswered JuniorNunes 4,886 -
0
votes2
answers492
viewsA: How to format date in firefox
firefox does not support pro date still, the ideal would be you use a javascript library to facilitate pro user, I recommend the datepicker of jqueryui: https://jqueryui.com/datepicker/ But if you…
-
1
votes3
answers246
viewsA: I need to check if my JSON is empty to search for url with parameter set in Curl
You can make an inline conditional to check if they are empty and assign the values accordingly, follow the example: marca = ( $('#marca').val() != '' ? $('#marca').val() : '' ); Note: It does a…
-
6
votes2
answers162
viewsA: Error while capturing JSON field?
On your foreach puts so: foreach ($resposta->messages as $c) { echo "$c->recipient<br>"; } What was happening is that your foreach was only passing the index date, so the first round…
-
1
votes1
answer504
viewsA: Retrieve data fields array() jQuery
You can get the data from your form using the .serializeArray jquery: var data = $('#enviar').serializeArray(); and pass in your ajax: $.ajax({ type: "POST", url: "php/salvarLote.php", data: data,…
jqueryanswered JuniorNunes 4,886 -
2
votes1
answer87
viewsA: Find the first tag after a class name and change it with jquery
Try it this way: $(".active").after(function () { $(this).find("ul:first").toggleClass("in"); }); Can do direct too: $('.active ul:first').toggleClass('in');…
-
2
votes1
answer2156
viewsA: Place emoticons in my website’s chat
In javascript you can do so: Use [:Smile] and [:Sad] to generate the emoticons. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <textarea…
-
0
votes1
answer84
viewsA: Link to an external page does not work
This function of yours is blocking: $('.templatemo-top-menu .navbar-nav a').click(function(e){ e.preventDefault(); var linkId = $(this).attr('href'); scrollTo(linkId);…
-
3
votes3
answers585
viewsA: Selecting the VALUE of a select with javascript or jquery
Example in pure Javascript: <select id="select"> <option disabled selected>Escolha...</option> <option value="aaa">AAA</option> <option…
-
3
votes1
answer32
viewsA: Remove object over time
You can use setTimeout together with jquery’s Hide, follow the example: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="modal">…
-
1
votes2
answers1489
viewsA: How to execute one code only after finishing another?
You can use the option async ajax as false, read more here: http://api.jquery.com/jquery.ajax/ This way the script waits the whole process to finish to give continuity to the code below. Example of…
-
0
votes3
answers191
viewsA: Enable/disable input text generated by a loop with data received from the database
What is happening in this case is that you are using the element ID to make your logic, the problem is that all the elements are with the same ID, I recommend you do otherwise: take the java script…
-
2
votes2
answers580
viewsA: Take JSON value and set AJAX behavior
Create a div with errorMessage id: <div id="errorMessage" style="display: none"></div> Then change your ajax to: $.ajax({ type: "POST", url: "teste.php", data: dados, success: function(…
-
2
votes1
answer517
viewsA: Fill a div when selecting a select item (form)
You would need to make an ajax request for a PHP script with the information the user chooses in select! This script will capture the value the user chooses in select:…
-
0
votes2
answers706
viewsA: Validation in Laravel 5 in array fields?
You can use an asterisk to symbolize any field of the array (name.*), I didn’t understand exactly what you want, so I advise you to take a look at the Laravel documentation in the array validation…