Posts by Miguel • 29,306 points
758 posts
-
6
votes5
answers839
viewsA: How can I add a value to a Row in the comic without having to add variables?
You need to be sure what kind of data that column (in this case saldo) store is numerical. To select the results so that only data with + 50 is displayed. You can do: SELECT saldo + 50 as saldo FROM…
-
1
votes1
answer528
viewsA: Loop in PHP to create array with PHP and Mysql
Experiment on the line where you insert the new value into the array, inside the foreach: ... $this->arrayPrStatus[] = $this->get_row['status_pr_status']; ...
-
6
votes2
answers154
viewsA: Create a vertical Label or Input
Here is an example of how to put the vertical text in another element: var ele_input = document.getElementById('vert'); var ele_text = document.getElementById('put-text');…
-
1
votes2
answers92
viewsA: Regex to take a parenthesis and string inside together
Do so: var str = 'cargo diretor (a)'; var regex = /\((.*?)\)/; str = str.replace(regex, '').trim(); alert(str); EXAMPLE in jsfiddle To obtain only the post (and if before the post is always "post"):…
-
0
votes2
answers97
viewsA: Mechanics Caroussel bootstrap, slide show
Done, I did the following: var item_width = $('#slider-wrapper .item').width(); var num_of_items = $('#slider-wrapper .item').length; var index_item_on = 0; $('#slider-wrapper').width(item_width *…
-
3
votes1
answer561
viewsA: Return to the previous page by setting a variable
To get the previous url: document.referrer To redirect to the previous url with additional parameters: window.location.href = document.referrer+ '?a=1';…
-
3
votes2
answers22
viewsA: Remove character from a generated value
Do so function remove_chars(num) { var str_num = String(num); if(str_num.length > 4) { var removals = str_num.length - 4; str_num = str_num.slice(0, -removals); } if(isNaN) { return str_num; }…
javascriptanswered Miguel 29,306 -
3
votes2
answers97
viewsQ: Mechanics Caroussel bootstrap, slide show
I’m trying to 'copy' the mechanics of boostrap Caroussel (http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_carousel&stacked=h). Forward walks well, it is not the same mechanic of the…
-
2
votes3
answers72
viewsA: Make copies of lists at certain positions with Python
Actually to copy the last five of them to another list: l2 = l[-5:] # l2 = [11, 12, 13, 14, 15] To remove the last five: del l[-5:] # l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]…
-
1
votes1
answer1178
views -
1
votes2
answers74
viewsA: Choosing an index from a list
Now I can’t test but I think you can do: index1 = 6 index2 = 14 vals = [] for i in range(0, 5): # l[index1:index2] = lista dos valores entre index1 e index2…
-
1
votes2
answers77
viewsA: Page height with javascript, take the user to a point of the page
Is this it? Display the attributes date $('[data-vestuario]').on('click', function() { var seccao = $(this).data('vestuario'); $('html, body').animate({ scrollTop: $(seccao).offset().top, // animar…
-
4
votes1
answer2249
viewsA: 2 gifs alternating the same space (frames loading correctly)
If I understand correctly this is what you want, the gif is completely removed and replaced so it always starts in the first frame of each, just have to adjust where it is 1000 (delay) for 6000,…
-
2
votes2
answers125
viewsA: Do not let php access via browser url
Here are two alternatives that make this task of the "smart guy who likes to rummage through the source code" quite difficult for this context. 1 - Ensures that it can only generate every 30 secs:…
-
6
votes2
answers447
viewsA: How to make a loop that compares string with a python float?
Simple attempt to transform into float (with this you can know if the typed string has the same shape as a float): h = input("Informe sua altura: ") try: float(h) print('É float, altura: ' ,h)…
-
1
votes2
answers1348
viewsA: Create an image with dynamic text overlay and send by email
Do so, I put adjust in front of the commands you should adjust in your case: if($_SERVER['REQUEST_METHOD'] == 'POST') { if(isset($_POST['texto'], $_POST['imagem'], $_POST['email'])) { $jpg_image =…
-
0
votes1
answer955
viewsA: Nav-tabs bootstrap by setting active in the URL
You can, for example, access http://exemplo.com#listaReservas: <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> <script…
-
1
votes3
answers97
viewsA: Check the existence of the values of one array in the Keys of another
Can do only with a foreach, and go seeing from the keys there are one by one: $hey1 = array( 0 => array( 0 => '{2}', 1 => '{3}', 2 => '{0}', 3 => '{2}' ) ); $hey2 = array( 0 =>…
-
2
votes1
answer1312
viewsA: How to use Animate.css + wow,js
Can use wow js., compatible with all animations of Animate.css: new WOW().init(); div { height: 600px; width: 300px; } .inner { width: 200px; height: 100px; background-color:blue; } <link…
-
1
votes1
answer227
viewsA: How to change the "code" content of a javascript section
If I understand what you want, I think this is it: var btn = document.getElementById('btn-sect1'); var sect1 = document.getElementById('sect1'); btn = btn.addEventListener('click', function() {…
-
4
votes1
answer5711
viewsA: Checking and creating python directories
Do so: import os.path # nao tenho bem a certeza se e isto que quer, nao sera: if username == 'USERNAME CORRETO' and password == 'PASSWORD CORRETA': ? if username != None and password != None: pasta…
-
1
votes2
answers66
viewsA: Search something in a list and say whether it exists or not - Display Value, and amount
Do so then: $produtos = array( 'Leite' => array( 'preco' => 1.5, ), 'Chocolate' => array( 'preco' => 10, ), 'Pão' => array( 'preco' => 3.5, ), 'Sal' => array( 'preco' => 0.5,…
-
2
votes2
answers553
views -
4
votes1
answer62
views -
1
votes1
answer1104
viewsA: hide <option> with javascript
Display in options does not always work well, however it may disable these options function mostraForm(valor) { if (valor === "MA") { document.getElementById("margem").style.display = "block";…
-
3
votes5
answers9322
viewsA: How can I generate a 7-character alpha-numeric key?
Here is another alternative to generate a 7-character pseudo-random string, including uppercase, minuscule, and number: $upper = implode('', range('A', 'Z')); // ABCDEFGHIJKLMNOPQRSTUVWXYZ $lower =…
-
1
votes3
answers2364
viewsA: How to assign "Selected" to a dynamic option?
I think that must be it var val_produto = 3; // value do produto que queremos selecionar var descricao = 'produto muito bom'; var opts = ''; for(var i = 0; i < 10; i++) { // tento simular o seu…
-
1
votes1
answer46
viewsA: allowing access to the webserver only with android
For android detection, using htaccess try: RewriteEngine On RewriteCond %{HTTP_USER_AGENT} "android" [NC] RewriteRule ^(.*)$ /android/$1 [L,QSA] # redirect aqui RewriteCond %{HTTP_USER_AGENT}…
-
3
votes3
answers270
viewsA: Simplifying an Array - PHP
Do so: $array = array( array( array( 'Brasil', 'França', 'Italia', 'China' ), ), ); $new_array = array_reduce($array, 'array_merge', array()); $new_array = array_reduce($new_array, 'array_merge',…
-
3
votes1
answer590
viewsA: Alert only once Session
I think what you want in this context is by convention called flash of a message, appears once and 'self-destructs'. That’s how: When you log in, let’s imagine that you do so (actually how you do it…
-
2
votes2
answers67
viewsA: how to place this in an html document
It’s almost just copy/paste, and put in the right places. In this case I added from <!DOCTYPE html> until </head>, and within the <head> put the css (also inside the tag…
-
1
votes2
answers228
viewsA: Dropdown menu bootstrap
I think the problem was some opening/closing errors of some html tags: Correction: <div class="navbar navbar-fixed-top navbar-default" role="navigation"> <div class="container"> <div…
-
2
votes2
answers332
viewsA: Save Date in UTC Brazil Table
Can go to config/app, and change the timezone: 'timezone' => 'America/Sao_Paulo', I believe that this already solves your problem, I leave here the list of American timezones, I think it must be…
-
3
votes1
answer2945
viewsA: How to take the value of a select and fill in an input?
You can do it like this, I did it to show up at onchange select $('#selectNames').on('change', function() { $('#myModal #nomePessoa').val($(this).find('option:selected').text());…
-
2
votes4
answers1058
viewsA: Get the first 2 user names
Check to see if you have 2 or more names in case you only have one name, using the Klaider solution: $names = explode(' ', Auth::user()->name); // Array ( [0] => Raylan [1] => Soares [2]…
-
2
votes3
answers1869
viewsA: How to make '$_SERVER['REQUEST_URI']' accept GET variables
Can do with strpos, can be used to see if a string contains any set of chars: if(strpos($_SERVER['REQUEST_URI'], '/painel/cardapio.php') === False) { // caso não contenha vamos redirecionar…
-
4
votes1
answer1745
viewsA: Take the name and date value (using datepicker), and then calculate using only (JQUERY),
var esteAno = new Date().getFullYear(); $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy', onSelect: function(date) { var ano = date.split('-')[2]; // ano aqui var anos = esteAno - ano;…
-
1
votes1
answer55
viewsA: Error mounting Foreach Laravel 5.1
With Compact doesn’t work. Do it like this: Controller: return view('administrator.images.index', ['categoria' => $categoria]);…
-
2
votes2
answers244
viewsA: Adding more input with jQuery
I believe this is what you want: $('input[name="qtd"]').on('keyup click', function(){ var qtd = $(this).val(); $('#inputs table').remove(); if(qtd > 0) { var appending = '<table>'; for(var…
-
1
votes2
answers61
viewsA: How to Make Case/Swictch Paged Control
With switch maybe it’s not the best way, but if you’re sure it’ll always be five pages you can do it like this: var conta = 1; function span_click(eleIndex) { var eles =…
javascriptanswered Miguel 29,306 -
2
votes2
answers57
viewsA: Callable in Javascript
See if this goes with what you want var graphFuncs = { grafico01: function() { alert('função grafico1'); }, grafico02: function() { alert('função grafico2'); }, grafico03: function() { alert('função…
-
2
votes2
answers642
views -
1
votes2
answers47
viewsA: html Javascript does not accept empty data
These properties you search for are invalid (Undefined), do the following: function validar(){ var allOk = true; if(document.getElementsByName('Nome')[0].value == '') { alert("Falta nome"); allOk =…
-
2
votes2
answers413
viewsA: Problem with @media query
Change this line @media screen (min-width:480px){ for: @media screen and (min-width:480px){ EXAMPLE in jsfiddle Note that so the styles that are set in within that media querie are applied when the…
-
1
votes3
answers1509
viewsA: How do I resolve this conflict in php?
Without modifying php, I don’t know, but modifying might solve this. I tested it here, in a Ubuntu/apache, try setting the header: header('Content-Type: text/html; charset=utf-8'); Or, instead of…
-
1
votes3
answers6169
viewsA: lock enter inside an input
Use the event for all inputs but excludes that: $('input').not('#auto').keypress(function(e) { if(e.which == 13) { // se pressionar enter console.log('pode submeter'); // aqui pode submeter o form }…
-
1
votes2
answers55
viewsA: How to adapt this function to work without needing the element ID?
This way you can select elements with standard css selectors. querySelector() returns an element (the first one you find), or none (if there is no element with the desired property) Already…
-
2
votes1
answer4573
viewsA: HTML - Customize checkbox put image and remove icon from checkbox
Try so, based on this example: input[type=checkbox] { display:none; } input[type=checkbox] + label { background-size:cover; background-position:center; background-repeat: no-repeat; height: 25px;…
-
1
votes1
answer24
viewsA: Sending Email on Server
Try so, the problem are often the default headers, should set them, mainly the From and the Reply-To $body = 'corpo da mensagem'; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:…
-
14
votes1
answer3557
viewsA: Is there a difference when merging two arrays with array_merge or with "+"?
There are two differences between + and the array_merge(): Operator +: When we use this operator in the case of elements with the same keys (whether they are numerical or not) the values of the left…