Jump to content


Popular Content

Showing most liked content since 02/17/2018 in all areas

  1. 1 point
    Seems odd to me that you declare all of the instance variables as public. It is more normal to make them private.
  2. 1 point
    This selector only targets the first direct children element/s of a parent element, not including any hierarchical child element/s of the first direct child element/s within it.
  3. 1 point
    IF you do it correctly $("input[data-class='resultdate'"] Should be $("input[data-class='resultdate']")
  4. 1 point
    It is an attribute, so the usual attribute selector will work.
  5. 1 point
    When you use jQuery and its plugins they often put additional classes on the elements. See if any of the class methods in jQuery help solve your problem, if not then you probably should use data attributes instead of the class attribute to store data. Here's how data attributes are defined: <element data-something="value1" data-somethingelse="value2"> In jQuery you can access the value of data attributes using the data() method: http://api.jquery.com/data/#data-key
  6. 1 point
    The first thing you should do is try the code yourself to see if it works. I don't see any obvious errors, so I would guess that it does work, but is unsafe on a few levels. I've removed the database information from your post to keep your accounts safe from people reading the forum. Your SQL query is open to SQL injection. Read about prepared statements to keep your database safe from hackers.nencrypted The passwords are openly visible in the database. It is unsafe for the people signing up to your site because you, and anybody with access to your database, know their passwords and you can use that to hack their accounts on other websites since many people use the same password in multiple places. To solve the password issue, you hash the passwords before storing them into your database using password_hash(). When searching for a user, you have to search by username first, pull out a hashed password and compare it to the data that was sent in the form using password_verify().
  7. 1 point
    The asynchronous nature of AJAX means that the code inside the done() and fail() methods only begin running long after the loop ended. Given your current code structure, the easiest way to solve it would be to keep track of whether it was sent already in a global variable. The following code will only work if the noticeSent variable is in the global scope. First define the global variable outside of the loop. var i; var noticeSent = false; for (i=0; i< feeid.length; i++) { When an AJAX response is returned, check the noticeSent variable and only send the notice if it hasn't already been sent: if (sendnotice == "Y" && !noticeSent) { noticeSent = true;
  8. 1 point
    Step 1 is complete. We have verified that clicking the button does not fire the form submit event. Now we have to find out why. Keeping the code the same as in my previous post, verify that you are using <input type="submit"> and not <input type="button">. If you're using "button" then change it to "submit" and test again. If that was not the issue, the next step is to make sure that you have no form validation attributes. Attributes like "required" will prevent the form from submitting. If the issue is still occurring after that then reply here with your form's HTML structure and the small block of code that handles the form's events and we can move on from there.
  9. 1 point
    This forum has nout to do with w3schools.com tutorials, check near bottom of tutorial page and click REPORT ERROR link, though I think you will find 'filetoupload' refers to file input name retrieved from form.
  10. 1 point
    Its not a good idea to use variable names such as form or input, as dot notation uses a similar method you are using, so confusion can arise. Even using id reference name similar to function name can cause issues.
  11. 1 point
    You need the defining of x to be in the function itself. At the moment as the page loads from top to bottom and when it reaches the var x = bit, the input at that time is blank, and it never gets updated when function is triggered.
  12. 1 point
    You can access the server's filesystem using a server-side programming language like PHP. If you want to access files on the user's computer you'll have to create a desktop program in a language like C++ or Java and ask the user to download and run it.
  13. 1 point
    Looks like you're missing the opening double quote for type="text". Your browser developer tools is very useful for these situations or any situation. 😉
  14. 1 point
    I can change the width of the input in Chrome, but it seems the submit button remains below. It's not behaving the usual way, but I just found that the parent element has display: flex. That would explain the unusual behaviour and why 100% width is working in Firefox. Since form inputs are very tricky to style, I would recommend not making them direct children of a flex object and instead wrapping each one in their own container. The parent element would have "display: flex" as it is now, but the children are now <div> or <span> elements that contain your inputs, you can set the flex property for each of these.
  15. 1 point
    If the database has rows containing "coffee / tea" in the sub_category field and the code is exactly as you presented, then the issue has to be occurring either where the variable was set, or in the code that loops through query results. Start by verifying that $var has the data you expected it to at the moment the query runs.
  16. 1 point
    If that code above has the click handler, I see one for podcast_link elements that isn't going to do anything. You prevent the default behavior, get some data, and that's it.
  17. 1 point
    If you run that query directly on your database, it returns the results you expect? I mean, you have at least one row where the sub_category field is set to "coffee / tea"?
  18. 1 point
    <input type="submit" value="Enviar"> That's all you have to do.
  19. 1 point
    How can you know if the error is fixed if you don't know what you're creating?
  20. 1 point
    You can use the condition `created_on` < DATE_SUB(NOW(), INTERVAL 3 HOUR). It uses the DATE_SUB() function.
  21. 1 point
    The code you presented is trying to create a table with two fields, each of type "VARIABLES," but "VARIABLES" is not a valid data type. My guess is that whoever wrote the query intended to write VARCHAR.
  22. 1 point
  23. 1 point
    To build a more complex program out of a lot of simpler parts, you first make a general outline of what the program should do as a collection of simpler steps. The following list is probably similar to the structure of the program you want to make, but you can tweak it if necessary: 1. If the form was submitted: 1.1 Collect the form data 1.2 Validate the form data 1.3a If the form data is valid: 1.3a.1 Save to database 1.3a.2 Redirect to another page 1.3a.3 End 1.3b If the form data is not valid: 1.3b.1 Show error messages 2. Show the form Now, for each step in the list you can write the PHP code for that step. This example uses just one form field for demonstration: <?php // 1. If the form was submitted if(!empty($_POST)) { // 1.1 Collect the form data $first_name = isset($_POST['first_name']) ? $_POST['first_name'] : ''; // 1.2 Validate the form data $is_valid = true; $errors = []; if(strlen($first_name) < 2) { $is_valid = false; $errors[] = 'First name is too short'; } // 1.3a If the form data is valid: if($is_valid) { // 1.3a.1 Save to database $pdo = new PDO("..."); $stmt = $pdo->prepare('INSERT INTO `table` (`first_name`) VALUES(?)'); $stmt->execute([$first_name]); // 1.3a.2 Redirect to another page header("Location: http://example.com/complete.php"); // 1.3a.3 End exit; } else { // 1.3b If the form data is not valid: // 1.3b.1 Show error messages echo 'Form errors:'; echo '<ul>'; foreach($errors as $error) { echo '<li>' . $error . '</li>'; } echo '</ul>'; } } // 2. Show the form ?> <form method="POST"> ... ... </form>
  24. 1 point
    From my understanding that's what it means.
  25. 1 point
    No, utf-8 is not a valid ISO language code, it's not a language at all. It's a character encoding. But only telling the browser which character encoding to use is not enough either, you need to actually use that character encoding. If you have some web page that you saved using a Windows Latin encoding and you're telling the browser that it's UTF-8, things aren't going to be displayed correctly. I don't know if I would make the assumption that every modern browser on every platform implements all 1,112,064 valid UTF-8 code points. You only need to find one browser not implementing one character to make that entire assumption false. I try to avoid absolute statements like that, especially when they're only assumptions. According to the MDN documentation, that is not valid.
  26. 1 point
    I'm the CTO for a small company that makes online learning courses and software.
  27. 1 point
    If you want to just refresh that specific div content without refreshing/reloading the whole page, you then need to look into AJAX which will use both, JavaScript to set a time to refresh the content by going to a php page and retrieving the content produced by that page to insert into that specific div.
  28. 1 point
    x modulo 20 should always be a number smaller than 20. Since 33 is greater than 20 that equation is false. I'll be using "%" as a shorthand for modulo since most programming languages do that. If you ask me how to find a number that satisfies the equation x % 20 = k, I'd go by the definition that the modulo is the remainder of the division. This means that the equation can be rewritten as this: (x - k) / 20 = n, where n is any natural number. Solving for x you would get x = 20 * n + k. There are as many solutions as values of n. Since there are infinite natural numbers there are infinite solutions. Since k cannot possibly have 33 as a value, here are a few solutions for k = 10 instead: 30 % 20 = 10 50 % 20 = 10 70 % 20 = 10 150 % 20 = 10
  29. 1 point
    Concatenate the values before printing them. var s = "hello w3schools how are you doing"; var output = ""; for(i = 0; i < s.length; i++) { output += String(s.charCodeAt(i)) + " "; } console.log(output);
  30. 1 point
    At the bottom of every manual page there's a comments section. In that section you'll often find interesting additional information about the topic at hand. The same goes for the PHP manual too. From reading peoples' comments on the page you just linked to, it seems like a search term that occurs in more than 50% of the records is ignored. That may or may not be the reason you're having trouble.
  31. 1 point
    No, there is not a way to do that in any of the major browsers.
  32. 1 point
    I agree that array superglobals in PHP act no differently than any other array. The only difference between a superglobal and any other variable is an entry in one of PHP's internal tables that keeps track of scope, where a superglobal is always in scope. That's the only difference. It is not a different kind of data type than you can use in any other part of PHP. That's why I was saying that it does not matter that it's a superglobal, you check for the existence of values the same way as you do with any other array. Why is that excessive? Do you think there should be a way to check all of the keys at once, and if so, how do you do that? Don't you have to check each one individually no matter how else you do it? If you want to write a function to take an array and a second array of keys, and return true or false if the first array contains every key in the second array, you can do that, but I don't know what the big deal is. It's not like I'm spending a lot of time checking if array keys exist, that's a small part of programming. This is probably the largest discussion I've ever had about checking if array keys exist, it's just not a big deal to verify that things exist before trying to use them. You have the isset function for most cases, and the empty function for the case where you're trying to check if the value exists and contains a non-falsy value.
  33. 1 point
    Not off the top of my head, but the front-end search box is pretty simple. At the most basic it's just a text field. If you want features like autocomplete or showing some partial matches you could click on then I'm sure you can find plugins to do all of that, or it shouldn't be too bad to put one together with the other stuff in jQuery.
  34. 1 point
    If you want to work on an existing project, either look for ads where they're asking for people to hire, or just find a project you like and volunteer. If those are the only languages you know then you'll only be able to work on front-end stuff.
  35. 1 point
    If you intend to select and copy the result it might be better to print the result onto the page instead. var s = "hello w3schools how are you doing"; var output = ""; for(i = 0; i < s.length; i++) { output += String(s.charCodeAt(i)) + "<br>"; } var div = document.createElement("div"); div.innerHTML = output; document.body.appendChild(div);
  36. 1 point
    Superglobals are literally PHP arrays. The only difference between a regular PHP array and a superglobal is that the superglobal is accessible from any scope. You can read all the details about arrays here: http://php.net/manual/en/language.types.array.php In PHP, arrays behave similar to the map structure in other languages. Here's a PHP sample of managing an array. not necessarily a superglobal, just any array. <?php $data = []; if(isset($data['something']) && $data['something'] == 'value') { echo 'The array contains the key "something" with value "value"'; } ?> Here's the same code using a map in Java: Map<String,String> data = new Map(); if(data.containsKey("something") && data.get("something").equals("value")) { System.out.println("The map contains the key \"something\" with the value \"value\""); } Notice that in both cases, we see whether the key exists before trying to retrieve a value associated with the key.
  37. 1 point
    Anytime you're checking for input values in POST, GET, or COOKIE you should use isset () to check that they exist before doing any operations with them. This is not new to PHP. My guess is that previously you had warnings turned off. Using empty () also works since it uses isset () internally.
  38. 1 point
    I can not fix this script, because the output is not in sync. I have 3 arrays. 1) present column names. 2) prefix (fixed name). 3) suffix (uniqid value). Can someone explain how exactly I should create a foreach loop in a foreach loop with 3 arrays and fetching the field value from the get_result command as the the value it is related to. This would result in: <---->Present Column Name <-----> New Column Name <---->value1 <--------------------------------> value1_abcd <---->value2 <------------------------------> value2_abcd etc. <?php $prefix_arr = array( 'col_a' , 'col_b' ,'col_c' , 'col_d', 'col_e' , 'col_f' , 'col_g' , ) ; $col2 = uniqid(); $suffix = substr($col2, 5, 11); $servername = "localhost"; $username = "userx"; $password = "pass12345"; $dbname = "test_database"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("SHOW COLUMNS FROM table_xyz"); $stmt->execute(); $res = $stmt->get_result(); $pres_colname = $res; // var_dump($prefix_arr); foreach ($prefix_arr as $los_ele){ $prefix = $los_ele; // var_dump($prefix); // var_dump($suffix); $col_new = $prefix."_".$suffix; //var_dump($col_new); foreach ($pres_colname as $val){ $col = $val['Field']; // var_dump($col); ?> <br><input type="text" value =" <?php echo $col; ?>"><input type="text" value ="<?php echo $col_new;?>"> <?php $stmt = $conn->prepare("ALTER TABLE `table_xyz` CHANGE COLUMN `$col` `$col_new` VARCHAR(30) NOT NULL;"); $stmt->execute(); } } //$stmt->close(); $conn->close(); ?> The complicated thing this time is that I need the exact 'Field' value which is an output of get_result, so I can not fit it in.
  39. 1 point
    The styling of form elements is very restricted. You can read more about it here: https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Styling_HTML_forms You can't style optgroup elements. If it's very important to give style to a structure similar to that one you'll have to create your own imitation of a dropdown using Javascript.
  40. 1 point
    OR use array $pr_ar $key in foreach to apply index key ref to the newly created array item each loop $pr_ar = array(0 => 'cola', 1 => 'colb', 2 => 'colc', 3 => 'cold'); $unique = uniqid(); $suf = substr($unique, 0, 11); foreach ($pr_ar as $key => $pre) { $new_col = $pre . $suf; $cna = []; $cna[$key] = $new_col; var_dump($cna); } ?> It will give the correct result from your previous post, but why create another array? just gather the string value on each loop, and use to rewrite column name, if this is to used to change column names? as indicated by another topic.
  41. 1 point
    I wouldn't recommend using this code. First, there's a polyfill to define document.getElementsByClassName if it's not already defined, that's there to support browsers older than IE11. document.getElementsByClassName is supposed to return a list of elements that have a particular class. That's all the result array is used for. That's the list of matching elements that gets returned. The addTracker function is supposed to be a cross-browser way to attach an event, but it's not written correctly. Spot the error: if (obj.addEventListener) { obj.addEventListener(type, fn, false); } else if (obj.addEventListener) { The get_targeted_links function is going to immediately send a tracking request for all links on the page, it does not wait for them to be clicked. In fact, nothing happens when they are clicked. That's where he sets the source of a new image to the PHP page. The browser will send a request for that URL. That's a rather lazy way of sending data to the server. Ajax communication has been possible since IE5, I'm not sure why he describes setting the src of an image as "genius". About the only thing that will do is only cause 1 tracking request per user because the browser will cache that URL thinking it's supposed to be an image. That "addTracker" function is just supposed to assign an event handler to an element. We already have terminology for that so I'm not sure why he's calling event handlers "trackers". Then, finally, all he's doing is tracking page clicks. That would only be useful if he's trying to track clicks to external websites, otherwise his own web server is already keeping logs of every page the server sends out, and there are plenty of statistics packages to analyze server logs. Then there are things like Google Analytics which will capture the same kind of information and a whole lot more. So I'm not sure how much information he's really gathering that's going to be useful. The save_click function also has a while loop at the end that compares the current timestamp to a variable called then, but he never sets the value of then. I'm not sure what the point of that loop is, but you never want to use infinite loops in Javascript, you'll bring the browser down. There's always a better way to do something than have a while loop keep going until the time changes.
  42. 1 point
    Unless its changed, focus is limited to inputs and anchor elements, so targeting elements other than these is your problem. From https://api.jquery.com/focus/ The focus e vent is sent to an element when it gains focus. This event is implicitly applicable to a limited set of elements, such as form elements (<input>, <select>, etc.) and links (<a href>). In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property. An element can gain focus via keyboard commands, such as the Tab key, or by mouse clicks on the element.
  43. 1 point
    My solution is to use click/touch instead of hover. Keep in mind also that hover doesn't work on mobile devices, the browser doesn't know when you're just pointing at something.
  44. 1 point
    The main issue is the animation. If you eliminate the animation, you're eliminating the window of time in which the user can move the mouse over to a different element. It's a design flaw to have content that changes the location of elements on mouseover and mouseout events because it makes it difficult for the user to reach elements they want to get to. Whenever anything causes elements to shift around, it's always better to use click events for it so that any rearrangement that occurs was intended by the user.
  45. 1 point
    If you have a solution to a common HTML or XHTML problem, you can PM me. Please provide the problem and solution with a reference to the website where you found this (if applicable).HOW DO I Make a Guestbook in HTML? Make a Forum in HTML? Make a Blog in HTML? Send emails from a form in HTML? The short answer is, you can't. Basically, any site where you want the visitor/client/user to be able to interact with something on the website, you need what is called Serverside Technologies, that is a Programming Language that executes commands and processes the input from the visitor/client/user, and a Database of some sort that the Programming Language can use as storage space. Look under "Server Scripting" and ".NET (dotnet)" for some popular Programming Languages. Some more that (as of now) are not covered by w3schools include Cold Fusion (CF) and Java Server Pages (JSP) to name a few. TUTORIALS http://w3schools.com/html/default.asphttp://w3schools.com/xhtml/default.asp NOVICE Incorrect Nesting of ElementsElements in HTML cannot overlap each other. The following is invalid:<strong><em>Incorrect nesting</strong></em>In this example, the B element is intended to contain an I element. To be truly contained within the B element, the I element's end tag must occur before the B element's end tag. The following is valid:<strong><em>Correct nesting</em></strong>Using all lowercase letters in a DOCTYPEIn a DOCTYPE, the formal public identifier--the quoted string that appears after the PUBLIC keyword--is case sensitive. A common error is to use the following:<!doctype html public "-//w3c//dtd html 4.0 transitional//en">Here the formal public identifier (FPI) is all lowercase. The validator does not recognize the document as HTML 4.0 Transitional since the expected FPI for HTML 4.0 Transitional uses different case:<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">Missing a required sub-element of HEADIf you receive the error "Missing a required sub-element of HEAD", check that you have included the TITLE element in the HEAD. The TITLE element is required in all HTML documents.Uppercase letters in XHTML tagsIn XHTML, unlike HTML, element and attribute names must be all lowercase. For example, onMouseOver is an invalid attribute in XHTML, which requires use of onmouseover instead. Either is fine in HTML.Email form to yourselfYou'll need to define the action attribute in your form element. Like so <form method="post" action="mailto:myemail@domain.com">It is recommended to use server-side scripting languages such as asp, php, coldfusion... to handle a form. This way the user which submits your form won't need to have a mailing application on his computer and you have more power over the data that is sent to you.Linking within a documentLinks that link within a document work almost the same way as external links using the <A> tag. However, there is an extra step involved. With these types of links you have to create the link and the target.This is how you link to a specific section in a document.<a href="page.html#section1">section 1</a>When you are linking in the same document where the section is you may remove the url in front of the #.<a href="#section1">section 1</a>Here is how you set the section, this is where the link will go to.<a name="section1"></a> INTERMEDIATE Validation Problems with ASCII CharactersOne of the requirements of XHTML-Strict validation is to code certain characters in ASCII syntax. Below is a list of characters and the ASCII equivalents that must be used to achieve proper validation. & = &< = <> = >...Closing /When coding in XHTML you are required to close all non-closing elements with a / at the end.HTML: <img src="images.jpg" alt="">XHTML: <img src="images.jpg" alt="" />Here is a list of non closing elements: br, hr, img, input, link, meta and script (optional).Attribute MinimizationIncorrect: <textarea readonly>READ-ONLY</textarea>Correct: <textarea readonly="readonly">READ-ONLY</textarea>Same goes for selected, should be selected="selected".Deprecated ElementsOlder HTML tags and attributes that have been superseded by other more functional or flexible alternatives (whether as HTML or as CSS) are declared as deprecated in HTML4 by the W3C - the consortium that sets the HTML standards. Browsers should continue to support deprecated tags and attributes, but eventually these tags are likely to become obsolete and so future support cannot be guaranteed.<applet>, <basefont>, <center>, <dir>, <font>, <isindex>, <menu>, <s>, <strike>, <u> and <xmp>. ADVANCED When to use IDs and ClassesClasses aren't always necessary! If every <p> element is going to have the same style, adding a class to every paragraph is redundant at best.IDs should be unique on a page. Let me repeat that: don't reuse IDs! Remember that ID is an abbreviation for "identifier". Use IDs to target specific, individual elements.Classes are meant to be reused. They work great for things like alternating background colors in table rows. (Give every second row a class="alt-bg", for example.)When to use DIVs and SPANsOverviewThe primary difference between the <span> and <div> tags is that <span> doesn't do any formatting of it's own. The <div> tag acts includes a paragraph break, because it is defining a logical division in the document. The <span> tag simply tells the browser to apply the style rules to whatever is within the <span>.DIVThe <div> tag defines logical divisions (defined) in your Web page. It acts a lot like a paragraph tag, but it divides the page up into larger sections.<div> also gives you the chance to define the style of whole sections of HTML. You could define a section of your page as a call out and give that section a different style from the surrounding text.But that's not all it does! The <div> tag gives you the ability to name certain sections of your documents so that you can affect them with style sheets or Dynamic HTML.One thing to keep in mind when using the <div> tag is that it breaks paragraphs. It acts as a paragraph end/beginning, and while you can have paragraphs within a <div> you can't have a <div> inside a paragraph. SPANThe <span> tag has very similar properties to the <div> tag, in that it changes the style of the text it encloses. But without any style attributes, the <span> tag won't change the enclosed items at all.The primary difference between the <span> and <div> tags is that <span> doesn't do any formatting of it's own. The <div> tag acts includes a paragraph break, because it is defining a logical division in the document. The <span> tag simply tells the browser to apply the style rules to whatever is within the <span>. GOOD PRACTICE Quoting all attribute valuesExample: <td rowspan=3>Correct syntax: <td rowspan="3">This is required for XHTML.Lowercase tagsExample: <STRONG>Correct syntax: <strong>This is required for XHTML.Validate your codeAlways validate your code. W3C HTML/XHTML Validator REFERENCES http://htmlhelp.com/tools/validator/problems.htmlhttp://www.andybudd.com/archives/2004/08/m...n_css_problems/http://www.blackwidows.co.uk/resources/tut...mon-errors.htmlhttp://w3schools.com/tags/default.asphttp://dhost.info/profmemberone/Pages/deprecated.phphttp://webdesign.about.com/od/htmltags/a/aa011000a.htmmyself!