Leaderboard


Popular Content

Showing most liked content since 09/07/2011 in all areas

  1. 2 likes
    Like astralaaron said using closest class and the index class in jquery you can get the index of the tr, have a look at the fiddle. https://jsfiddle.net/8hL46ftj/ hope this helps $('img').click(function(){ alert($(this).closest('tr').index()) })
  2. 1 like
    If you want to look into it, figure out which router you have and look up how to configure it (there should be a web page GUI), and then you need to set up port forwarding, to forward traffic on port 80 to your server's IP address. You'll also want to make sure that computer uses a static IP from the router instead of getting a dynamic IP every time so you don't have to change the port forwarding rules.
  3. 1 like
    I don't know where there's a list. Generally you should never develop for specific devices, you should just make your layout flexible enough (with help of media queries) to wotk on any screen regardless of size. This is usually achieved by testing your page in the responsive mode of your browser and resizing the viewport until it breaks, then you add a media query to correct the layout. But for reference, I start off with a design for the following devices, then make extra adjustments later: Small mobile (iPhone 4):Up to 374px (I usually use this just for specific elements that didn't fit) Mobile or small mobile in landscape): Up to 767px Tablet portrait: 768px Tablet landscape: 1024px (breakpoint usually between 800px and 900px) Desktop: 1025px and above Some people make designs for large desktop computers (1440px and above), but that's up to you. In general, there isn't one specific strategy for responsive design, this is just the approach from the companies I work with.
  4. 1 like
    Its discussed here https://stackoverflow.com/questions/3366529/wrap-every-3-divs-in-a-div an example would be $(function() { var target_divs = $('.panel-grid-cell'); for (var i = 0; i < target_divs.length; i += 3) { target_divs.slice(i, i + 3).wrapAll("<div class='container'></div>"); } });
  5. 1 like
    That looks like a customized checkbox, not your ordinary plain checkbox. Its probably a created element with an awesome font character, so it depends on how this replacement is identified, styled and placed, not how the actual checkbox is identified, styled and placed.
  6. 1 like
    Have you tried this? <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title> HTML5 page </title> </head> <body> <div class="form-group"> <label class="col-sm-4 control-label">Checkbox inputs</label> <div class="col-sm-8"> <div class="checkbox check-transparent"> <label for="opt01">Option 1</label> <input type="checkbox" value="1" id="opt01" checked> </div> <div class="checkbox check-transparent"> <label for="opt02">Option 2</label> <input type="checkbox" value="1" id="opt02"> </div> <div class="checkbox check-transparent"> <label for="opt03">Option 3</label> <input type="checkbox" value="1" id="opt03"> </div> </div> <div> </body> </html>
  7. 1 like
    Yes, if you are only communicating via the internet, and not using a browser, but each language is different. You would not use the same code or probably even the same language in Windows as you would in Linux.
  8. 1 like
    You want what to happen, an anchor to get created or edited or something? Like with most things, instead of finding something that tells you exactly how to do specifically what you want to do, you need to understand the basics and the theory yourself so that you can apply that to build what you want. You can start here, but there's a lot more information online about dragging and dropping. https://www.w3schools.com/html/html5_draganddrop.asp
  9. 1 like
    Maybe they don't have example files on their server for you to use. You can open any other editor and add video and track tags if you want to though, as long as there are files online somewhere that you can point to.
  10. 1 like
    (1) All form element in your current setup should appear in between <form> and </form> (2) IF using $_POST! The idea is to set a value for each checkbox so when it is submitted it is sent as $_POST array with these values. (4) IF using $_GET! THIS " window.location.assign("deleteVideo.php?id=" + id); " is a $_GET querystring, so ALL $_POST['...'] in 'deleteVideo.php' should be $_GET['...'] instead (3) As these can be multiple values the value of name attribute, should reflect it will be an array of values as in "name='checkbox[]'" (4) The 'id' argument equals WHAT? in onclick="myFunction(id)", its just text or undefined variable? (5) How can $id exist or be defined if it has not retrieved yet! $sql = mysqli_query($database, "SELECT * FROM video WHERE id='$id'"); (6) You need to make your mind up which to use $_GET or $_POST, if using the $_GET by using JavaScript to open this page then empty($_POST['delete'] will never exist. IF sent through GET querystring you would have to use $_GET['..']; instead (6) This if($val=='checked') will never be true, the $id will equal index value of array holding the value which current does not exist? as there is no value assigned to that checkbox.
  11. 1 like
    That refers to a constant. It would be defined in the Feed class as const ATOM = 'Some value'
  12. 1 like
    I'm not sure what code you're using to get the mouse offset, but once you have it you can calculate the correct position by dividing the canvas real size by its visible size. // Assuming we already have a reference to canvas and the mouse's position // relative to it is in visibleX and visibleY var horizontalRatio = canvas.width / canvas.offsetWidth; var verticalRatio = canvas.height / canvas.offserHeight; var realX = horizontalRatio * visibleX; var realY = verticalRatio * visibleY; // Do something with realX and realY
  13. 1 like
    Place both if conditions for setting modal and login to display none, in a single window.onclick function
  14. 1 like
    First, IDs need to be unique, it's not correct to have the same ID on more than one element. And option elements don't have a "checked" attribute, checkboxes do. Option elements have a "selected" attribute. To make it easier, you can add a hyphen or something to each name, like "q1-opt1". In PHP you can get each of the values in $_POST (if the only things in $_POST are the select values, then you can just loop through $_POST), you can use explode to split up the name into parts like "q1" and "opt1", check the value they selected, and then you can save which questions they picked yes for.
  15. 1 like
    There are several problems with that upload code. The major one is that you are doing no error checking or validation on the file that was uploaded. If someone uses that form to upload a .php file, you'll just copy it to your server where someone can then access the URL, and now you're running some random PHP code that someone uploaded. That's probably the single easiest way to get your server hacked. You need to validate the file to make sure that it's allowed, and you also need to check for errors that may have happened during the upload: http://php.net/manual/en/features.file-upload.errors.php You also need to use prepared statements when you're sending data to the database. Don't put variables right into the query, use a prepared statement with placeholders that you can use to send the data separately to protect your database. The mysqli extension supports prepared statements: http://php.net/manual/en/mysqli.quickstart.prepared-statements.php To avoid re-submitting the form when someone refreshes the browser, after you finish processing the form you should send a location header to redirect the user. Then if they refresh they will only refresh the redirected URL instead of the form submission. You can redirect them to a thank you page, some other page that shows a message from the form, back to the form, etc. You should also move all of your form processing code to the top of your file, before any HTML output. If you're just going to end up redirecting the user there's no reason to send any HTML at all. The first thing the file should do is figure out if it needs to process or display the form, and go from there. For some reason you used an embed tag, you only need to use a video tag. Look up the video reference to see how to use that. You also messed up with the quotes in that string, if you view the source code of that page in the browser you'll see the problem.
  16. 1 like
    Upon refreshing, the video is still uploaded to database ? Not the folder, because i might be thinking that it displays you the page because in database there is a video saved with an url but on your host in the videos folder there is no video with the url from db, that's mostly why you have that error.
  17. 1 like
    You have not bound a parameter for the WHERE statment, for every ? There must be a type and variable/value defined in the same order.
  18. 1 like
    My suggestion is to add HTML DOM element object outerHTML attribute for the JavaScript reference. It seems that most, if not all, the browsers support this attribute. In addition, it is important and basic attribute that new JavaScript developers should know about.
  19. 1 like
    You can't have multiple functions of the same name, Like in the film 'Highlander' there can be only one.
  20. 1 like
    So, why use AJAX at all? Since AJAX depends on Javascript being turned on or off, and since this decision is made by the user-client, why not use PHP whose functioning is determined solely by the host-server?
  21. 1 like
    It would transfer the problem to AJAX code, it depends on WHY the ajax php code was included in the form page if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); will not run php code beyond this 'if' condition, if page reloads because JavaScript was disabled which prevents the form being submitted, it is no longer a JavaScript AJAX request. if (!isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); Will allow the php code within the form to be processed if JavaScript disabled, BUT! will prevent AJAX request being processed if JavaScript is enabled and it goes directly to ajax_comment.php
  22. 1 like
    OK. Thank you for the correction, Dsonesuk. I have never used AJAX and looked only for what was different from what I use -- namely, PHP. Upon a more careful reading I now see the statement include ("ajax_comment.php"); If I have further understood, you find the following statement to be ill-conceived, if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); and give as a reason that the PHP will only be used, if the Javascript succeeds. So, if Loois were to write, if (!isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); would this fix his problem.
  23. 1 like
    Its AJAX, it does not require those, without action the form will submit to itself, and as that php file is included in the form page itself, which maybe used to takes into account if JavaScript is disabled it will then as said be submitted, page reloaded and processed by the same page, BUT! currently it will only show if AJAX request is sent ($_SERVER['HTTP_X_REQUESTED_WITH']), which seems pointless including in the form page as a non JavaScript alternative. While with JavaScript enabled, the form is prevented from being submitted, it gathers the input data and sends it to the php file specified in the JavaScript AJAX url code to be processed and return the result without reloading of page
  24. 1 like
    The RSS file can go anywhere you want, you just have to tell people where to find it. As I mentioned earlier, you can tell browsers where to find a feed by putting a <link> tag in your HTML page. There's no real best practice as to where to place your RSS feed files. I think RSS feeds have to use absolute URLs in the <link> tags including protocol and domain name to point to the location of the files. If you want a URL like "/feed" for your RSS feed you would have to use URL rewriting on the server, a regular URL would look like this instead: "/feed.xml" or "/feed.rss".
  25. 1 like
    If you want to prevent the menu from hiding on mobile devices, remove the "w3-hide-small" class from the menu.
  26. 1 like
    Yep. The alternative is to not list the columns in the table and only give the values: INSERT INTO table VALUES ('val1', 'val2', 'val3') But, like I said, if you ever change the structure of that table then that query is going to break if you've changed the number of columns. It's best to just list everything out explicitly. You don't have to pay per character in your source code, make the code as obvious as possible so that it's easy to maintain. Ease of maintenance should always be a higher priority than something like how long the code is.
  27. 1 like
    If you're using mysqli in PHP then you still need to write the SQL code. mysqli is just an extension for using MySQL, it's not an abstraction layer like you would get with Zend Db or something where you're building PHP method calls instead of writing SQL queries.
  28. 1 like
    You should only need one function. First set up your buttons to each have a value: <button type="button" class="add-panel" data-value="4 Panel Smooth">Add 4 Panel Smooth</button><br><br> <button type="button" class="add-panel" data-value="4 Panel Grained">Add 4 Panel Grained</button><br><br> <button type="button" class="add-panel" data-value="4 Panel Grained 2 Glazed">Add 4 Panel Grained Glazed</button><br><br> Create the list that will contain the values: <ul id="demo"></ul> Set up an event listener for the buttons: var buttons = document.getElementsByClassName("add-panel"); for(var i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click", addPanel, false); } Create the event handler that updates the array and displays its contents in the HTML: var panels = []; function addPanel(e) { // Get a reference to the button that was clicked var button = e.currentTarget; // Add the button's value to the array panels.push(button.getAttribute("data-value")); // Display the contents of the array on the page by generating <li> elements. var demo = document.getElementById("demo"); demo.innerHTML = ""; var li; for(var i = 0; i < panels.length; i++) { li = document.createElement("li"); li.innerHTML = panels[i]; demo.appendChild(li); } }
  29. 1 like
    When you're printing each field you can check if the field ID exists in $non_matches, and style the element appropriately. I'm just suggesting that it is more efficient to print everything correct in the first place, versus printing everything then trying to run client-side code to show errors or whatever else.
  30. 1 like
    You can use scandir() to list files in a directory and generate the HTML for the images. The line breaks exist, but HTML doesn't render line breaks unless you specifically put a <br> element. You can use nl2br() to show line breaks in the text provided by users. You can't choose the size of a file, but you can give a size limit in the file uploader. There are plenty of PHP file upload tutorials, you should look at some of them. The W3Schools tutorial has sections explaining how to limit the file size and file type. You can use str_replace() to change substrings into something else, such as in the following example: <?php $string = str_replace(':)', '<img src="smiley.gif">', $string); ?>
  31. 1 like
    Depending IF the poster is already using jquery as all i see is plain vanilla JavaScript code, that would overkill just for one small line of code.
  32. 1 like
    You will need an array to store the values, on page load you will check localstorage to see if values already exist, if yes, update the array with these values, then as more values are submitted, add to array and localstorage.
  33. 1 like
    IF you are talking about multiple selection dropdown the value would contain 'Griffin,Swanson,Quagmire', so you would not need to change JavaScript, only the php side to split those names from $_GET['q'] For passing second variable, you have to run a function to retrieve the two values and apply to variables 'str' sames as before, and lets say 'home', then in ajax querystring xmlhttp.open("GET","getuser.php?q="+str+"&hometown="+home,true); Then in php $homeTown = strval($_GET['hometown']);
  34. 1 like
    Here's how you created nested elements: /* Create a container */ var container = document.createElement("div"); /* Create children */ var image = document.createElement("img"); //... Set attributes var paragraph = document.createElement("p"); // ... Set attributes and content /* Add children to the container */ container.appendChild(image); container.appendChild(paragraph); /* Add the container to the body */ document.body.appendChild(container);
  35. 1 like
    You should get in the habit of structuring your code like Ingolme mentions. Put your PHP code first that will decide what the page is even going to do, and output HTML and whatever later on. If you're just going to redirect there's no reason to output a bunch of HTML anyway, right? So figure out first if you're going to redirect or show HTML or whatever else, and then do that.
  36. 1 like
    You can store the query results in a multidimensional array check this https://www.w3schools.com/php/func_array.asp "example 4" you can then return the array .
  37. 1 like
    Use block elements, or turn them into block elements using display: block; or display: inline-block;
  38. 1 like
    Any inline element, or block element using display: inline; turning it into a inline element will not respond to width, height applied, its width will be determined by content within it.
  39. 1 like
    header > h1, header > p{ color:red; } /*OR*/ header > h1, header > h1 + p{ color:red; } /*Give header class name */ .colour_version01 {color:red;} <header class="colour_version01"> <h1>Some text</h1> <p>Some more text</p> </header>
  40. 1 like
    That would be fine if you were coding for a website, but HTML emails need to be simple. if you want it random, you'll have to create several different images with the pictures in different orders.
  41. 1 like
    <span class="fruit">apple</span> <span class="fruit">orange</span> <img class="fruit_img" src=""> <img class="fruit_img" src=""> <span class="fruit">pear</span> <img class="fruit_img" src=""> <span class="fruit">pineapple</span> <img class="fruit_img" src=""> <script type="text/javascript"> $(function() { $('.fruit').each(function(i) { $('.fruit_img').eq(i).attr('src', "http://placehold.it/400x150?text=" + $(this).html()); }); }); Note even though not all images directly follow the span element, the are given the correct url of image in same sequence. i is the span index starting from 0 with class name 'fruit', img elements with 'fruit_img' class, using .eq() and index of 'i' will target these specific img elements in same sequence as they set out in within the page..
  42. 1 like
    An id reference must be unique within a page, only class names can be used multiple times, so you would have to loop through classnames and make changes to next sibling img src attribute.
  43. 1 like
    Had to make slight change, correct invalid html, which you should validate at https://validator.w3.org/ before posting <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0" /> <title>Document Title</title> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <style type="text/css"> #mydropdown option:hover { background: #c8c8c8; } #mydropdown option { padding: 5px; } .mydivs1 { display: none; } br { display: block; content: ""; margin-top: 5px; } .mydivs1 { border: 1px solid black; padding: 5px; height: 211px; width: 172px; margin-left: 5px; background-color: #ff8080; } .mydivs2 { border: 1px solid black; padding: 5px; height: 199px; width: 35px; float: left; background-color: #b3e6b3; } .mydivs3 { border: 1px solid black; height: 199px; width: 103px; margin-left: 52px; padding-left: 10px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px; background-color: #cce6ff; } </style> </head> <body> <input type="text" id="mytextbox" placeholder="Search Foods"> <p></p> <select id="mydropdown" multiple="multiple"> <option value="optionx_Fruits">Fruits</option> <option value="optionx_Vegetables">Vegetables</option> <option value="optionx_Nuts">Nuts</option> <option value="optionx_Meats">Meats</option> </select> <p></p> Results: <p></p> <div id="results"> <div class="mydivs1" id="optionx_Fruits"> <!--match="optionx Fruits"--> <div class="mydivs2"> <button class="button1">X</button> <p style="clear:both"></p> <button class="button2">C</button> </div> <div class="mydivs3"> <span class="myspan1">Fruits</span> <p></p> <span class="myspan2">1:</span> <br> <span class="myspan3">Avocados</span> <p></p> <span class="myspan2">2:</span> <br> <span class="myspan3">Blackberries</span> <p></p> <span class="myspan2">3:</span> <BR> <span class="myspan3">Raspberries</span> </div> <p></p> </div> <p></p> <div class="mydivs1" id="optionx_Vegetables"> <!--match="optionx Vegetables"--> <div class="mydivs2"> <button class="button1">X</button> <p style="clear:both"></p> <button class="button2">C</button> </div> <div class="mydivs3"> <span class="myspan1">Vegetables</span> <p></p> <span class="myspan2">1:</span> <br> <span class="myspan3">Beets</span> <p></p> <span class="myspan2">2:</span> <br> <span class="myspan3">Eggplants</span> <p></p> <span class="myspan2">3:</span> <BR> <span class="myspan3">Spinach</span> </div> <p></p> </div> <p></p> <div class="mydivs1" id="optionx_Nuts"> <!--match="optionx Nuts"--> <div class="mydivs2"> <button class="button1">X</button> <p style="clear:both"></p> <button class="button2">C</button> </div> <div class="mydivs3"> <span class="myspan1">Nuts</span> <p></p> <span class="myspan2">1:</span> <br> <span class="myspan3">Almonds</span> <p></p> <span class="myspan2">2:</span> <br> <span class="myspan3">Pecans</span> <p></p> <span class="myspan2">3:</span> <BR> <span class="myspan3">Walnuts</span> </div> <p></p> </div> <p></p> <div class="mydivs1" id="optionx_Meats"><!--match="optionx Meats"--> <div class="mydivs2"> <button class="button1">X</button> <p style="clear:both"></p> <button class="button2">C</button> </div> <div class="mydivs3"> <span class="myspan1">Meats</span> <p></p> <span class="myspan2">1:</span> <br> <span class="myspan3">Chicken</span> <p></p> <span class="myspan2">2:</span> <br> <span class="myspan3">Fish</span> <p></p> <span class="myspan2">3:</span> <BR> <span class="myspan3">Turkey</span> </div> <p></p> </div> </div> <p></p> <!-- Original script --> <script type="text/javascript"> /* jQuery.fn.filterByText = function(mytextbox) { return this.each(function() { var select = this; var options = []; $(mydropdown).find('option').each(function() { options.push({ value: $(this).val(), text: $(this).text() }); }); $(mydropdown).data('options', options); $(mytextbox).bind('change keyup', function() { var options = $(mydropdown).empty().data('options'); var search = $.trim($(this).val().replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")); var regex = new RegExp(search, "gi"); $.each(options, function(i) { var option = options[i]; if (option.text.match(regex) !== null) { $(mydropdown).append( $('<option>').text(option.text).val(option.value) ); } }); }); }); }; $(function() { $('#mydropdown').filterByText($('#mytextbox'), true); });*/ /* $(document).ready(function() { function exists(elemt, arr) { return (jQuery.inArray(elemt, arr) > -1); } $('#mydropdown').change(function() { var $selected = $(this).val(); $('.mydivs1').each(function() { $(this).toggle()[ (exists($(this).attr('match'), $selected)) ? 'show' : 'hide'](); }); }); });*/ </script> <!--NEW Script --> <script> var SelOrderArray = []; $('#mydropdown').on('change keyup', function() { $('.mydivs1').hide(); var $selected = $(this).val(); if ($selected.length > 0) { $.each($selected, function(i) { //loop through selected possible multiple selected options if (SelOrderArray.indexOf($selected[i]) === -1) { //if current looped through $selected value not in array then add to array SelOrderArray.push($selected[i]); } }); } else { SelOrderArray.push($selected[i]); } // loop through ordered array of slected options $.each(SelOrderArray, function(i) { //clone element with specific id to temp storage variable var TmpDivClone = $("#" + SelOrderArray[i]).clone(); //remove current existing element with specific id $("#" + SelOrderArray[i]).remove(); // prepend temp cloned element to div #result wrapping mydiv1 elements so prepending remains below dropdown and show TmpDivClone.prependTo('#results').show(); }); }); </script> </body> </html>
  44. 1 like
    var SelOrderArray=[]; $.each($selected,function(i){ //loop through selected possible multiple selected options if(SelOrderArray.indexOf($selected[i]) === -1){ //if current looped through $selected value not in array then add to array SelOrderArray.push($selected[i]); } }); // loop through ordered array of slected options $.each(SelOrderArray,function(i){ //clone element with specific id to temp storage variable var TmpDivClone = $("#"+SelOrderArray[i]).clone(); //remove current existing element with specific id $("#"+SelOrderArray[i]).remove(); // prepend temp cloned element to div #result wrapping mydiv1 elements so prepending remains below dropdown and show TmpDivClone.prependTo('#result').show(); }); Not tested, written on tablet
  45. 1 like
  46. 1 like
    Buttons are inline elements, so they need to be centered by setting text-align on the parent element.
  47. 1 like
    With the code I provided, it does not require being placed in function, it runs its own anonymous function if a specific classed element within a specific parent id element is clicked even if a specific currently classed element already exists OR is newly created which is what 'on()' is specifically used for.
  48. 1 like
    If you want to use a database as the data store then that's one route to take, but if the data is static then you could get away with a CSV file or something. You wouldn't even necessarily need to use a server-side language like PHP to build the table (although you could), you could just send an ajax request in Javascript to get the CSV file and parse it in Javascript and go through it to build the table dynamically. Once the table is built and on the page then you'll probably just want to use a jQuery plugin or something for sorting and filtering.
  49. 1 like
    Please don't rot your mind with an editor!!!! :)You learn so much more by using notepad and hand coding. You develope much stronger coding skills. Even with .Net I use Notepad at home...I only us VS.net at work because I have to.Just my opinion though.
  50. 1 like