Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 12/12/2017 in all areas

  1. 2 points
    Included files must have <?php ?> blocks around the code.
  2. 1 point
    The computer doesn't care how many items are there, the only thing that matters is whether it follows the correct format. There are all kinds of text editors that will let you collapse whatever part of the structure you want. The built-in developer tools in the browser will do that also if you print the structure to the console. There sure is, and the browser does all of that automatically. I have never written code to parse a JSON structure, there's no reason to write that when it's a format the browser understands natively. JSON is native Javascript, it stands for Javascript Object Notation. The browser already understands it, you don't have to parse anything like that yourself. Yep. var obj = JSON.parse(json_str); console.log(obj);
  3. 1 point
    I don't understand the question. Replacing the contents of any element on the page is the same regardless of the content you're replacing it with. Methods of replacing content in an element do not change based on the content. I don't know if you're referring to appending content instead of replacing.
  4. 1 point
    The PHP manual says prior to any output. The reason being that it has to be in the HTTP headers section. If you have studied the HTTP protocol it should be clear. An HTTP response consists of two sections: The headers and the body. The headers provide information about the data being sent, such as the amount of bytes, the file type and also cookies. After the headers goes two line breaks and then the body. The body is the actual file contents. In order to be efficient, PHP goes sending data back to the client while it is still processing, which means that as soon as any content is printed, whether it be HTML or anything else, it immediately sends the two line breaks and enters the body section of the HTTP response. Once those two line breaks have been sent it is impossible to go back an send any more headers to the client because whatever you send is going to be considered part of the body. While PHP is usually used to send HTML, it can also send any other kind of content, like image data, a video or an excel file. PHP can output content of any kind, so saying that headers have to be sent before the <html> tag just covers the specific case that the first part of your output is the string "<html>". The general case is that the headers have to be sent prior to any output.
  5. 1 point
    On loading of the page the first time NOTHING if the cookie does not already exist, but the cookie will be set by the second line. The second time the page is loaded because the cookie now exists, the first line will cause it to be deleted, then the second line will set it again and the circle will start over delete, set on page load, delete, set on page load and so on... It will be deleted. NOTE: With your current code, it won't expire i.e be deleted, as the expiry date increases by 30+ days from current date everytime time it is loaded.
  6. 1 point
    AJAX is not the correct tool for this problem. Why do you insist on using it? I already gave a solution that does not require reloading the page, use Javascript. It does not need AJAX.
  7. 1 point
    The rawurlencode() and encodeURIComponent() functions transform any non-ASCII values into ASCII, that's exactly what they are for. I said query string components, which refers to these sections: ?a=component1&b=component2 If you do not escape =, ? and & in those values then you will not get the values you expect in the server. The following example is a query string that will not give the desired value on the server: ?candy=M&Ms. If you do not escape the &, then the server will see a key "candy" with value "M" and another key "Ms" with no value.
  8. 1 point
    You're measuring things they are clicking inside the iframe, right? If you're trying to measure things they click on the parent site from inside the iframe, you're not going to be able to do that because Javascript running inside the iframe can't interfere with the parent site if it's on another domain. If you're just trying to measure how many times the iframe gets shown, that's as easy as updating a database table every time your page gets loaded. That kind of terminology is part of why people are confused. You're not talking about linking to your site, you're talking about embedding an iframe. Those are completely different things. Linking to your site means putting an anchor tag on the page pointing to your site. That's not what you're talking about here. And if you're talking about "impressions", using the same terminology that advertisers use, then you're just counting page views for the page that's inside the iframe. That's what I described above.
  9. 1 point
    Because the link on clicking, does want it normally does (even though it is empty, it is still linking to itself) so the update of hidden input then submission does get a chance to execute. You need to prevent the anchor doing what it normally does with event.prevent.Default() php echo "<a href=\"\" onclick=\"examine('Hello',event)\">examine</a>"; JS function examine(parametre, e) { e.preventDefault(); document.getElementById('myinput').value = parametre; document.getElementById('myform').submit(); }
  10. 1 point
    It's not correct. Asynchronous is not about the order of execution, that is merely a side effect, but about whether or not the browser should halt loading the page when it comes across a script. HTML just tells the browser what scripts to load and how to load them. As for methods of loading Javascript, there are just two: synchronous and asynchronous. When a script is synchronous, the page stops loading at the point where the <script> tag ended, waits for the entire script to download, then runs the Javascript from the file, then continues loading the rest of the HTML. This really slows down the page from loading which is why it is recommended to have script tags at the bottom of the document or to load them asynchronously. If you load scripts synchronously in the <head> section then the page will be blank until the scripts are done downloading. When a script is loaded asynchronously, the page begins downloading the scripts but continues parsing the rest of the HTML on the page, waiting until the script has finished downloading before running it. The problem with this is that you cannot predict the order in which scripts will run: whichever script downloads the fastest runs first. The defer attribute tells the browser to remember the order in which scripts were in the document, but this behavior is only predictable if all script tags have the defer attribute and not just some of them. Most of the time, the defer attribute is not used for that purpose and instead is just used to be backwards compatible with old versions of Internet Explorer because it does not support the async attribute.
  11. 1 point
    Unless you are going to use the value of state from dropdown somewhere else, you can simply change the value from dropdown to the actual country that the text state of options is showing. You then wouldn't require any arrays just the retrieved value from selected state.
  12. 1 point
    The trouble with input of state you are relying on the user to enter the name correctly, thats why dropdowns are used. <form> <p><label>State of Birth: </label> <select id="state" name="state" onchange="autoFill(this)"> <option value="Queensland">Queensland</option> <option value="Tasmania">Tasmania</option> <option value="Florida">Florida</option> <option value="Victoria">Victoria</option> </select> <p> <label>Country of Birth: </label> <input type="text" id="country" name="country"> </p> </form> <script type="text/javascript"> var stateArray = [[0, 'Queensland'], [0, 'Victoria'], [0, 'Tasmania'], [1, 'Florida']]; var countryArray = ['Australia', 'America']; //0 from above is index to Australia, 1 to USA //Arrays always start from 0 function autoFill(elem) { var countryIndex = ""; for (i = 0; i < stateArray.length; i++) { if (elem.value === stateArray[i][1])//if value from dropdown matches looped thro state array 2nd state values { //store index value to country countryIndex = stateArray[i][0]; document.getElementById('country').value = countryArray[countryIndex]; // use index value to get country array value and show in input break; //stop loop } } } </script>
  13. 1 point
    How can you know if the error is fixed if you don't know what you're creating?
  14. 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.
  15. 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);
  16. 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.
  17. 1 point
    Yes. Is there anything in the included file db.php that produces printed output -- say, an echo(), print_r(), or similar such statement? Roddy
  18. 1 point
    Ex 2; https://validator.w3.org/nu/?showsource=yes&doc=http%3A%2F%2Fwww.grammarcaptive.com%2Fpodcast_hostpage.php%3Fhash%3D30a6836a3f7c5fc57751a61098e5c221%26podcast_no%3D21#l452c96 Compared to Ex 1 https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.grammarcaptive.com%2Fpodcast_hostpage.php&showsource=yes Ex 3 https://validator.w3.org/nu/?showsource=yes&doc=https%3A%2F%2Fwww.grammarcaptive.com%2Fpodcast_hostpage.php%3Fhash%3D30a6836a3f7c5fc57751a61098e5c221%26podcast%3D21 Even though they have errors, they don't have misplaced or extra closing elements, which is causing alignment issue because the wrapper only wraps the header and does not wrap sidebar OR footer elements. The wrappers bottom margin causes the misalignment of sidebar.
  19. 1 point
    This is how you increment the value of a field with an SQL query: UPDATE `field1` SET `field1` = `field1` + 1 WHERE `field2` = 'value' You probably will need to adjust this query to match your table's structure and software requirements. Since I don't have any information about your project or database structure I'm just providing a very generalized solution.
  20. 1 point
    Have you tried printing the stmt and result objects after the match attempt to see for errors? Also not sure if this may be the issue but I don't think you need to call the first line below because when calling 'prepare' it returns a stmt object for you. $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql_select); So instead try: $mysqli_stmt = $this->mysqli_obj->prepare($sql_select); Also noticed: $match = mysqli_num_rows($mysqli_result); Looks like calling procedural function calling attempt? Instead for number of rows, try: $mysqli_stmt->num_rows Use in the if condition instead of $match > 0. Also noticed and just to note, when calling a function from another function within the same object, use $this->update_record(); instead of just update_record(); Good luck! I'm sure some of the others will be here to assist as well!
  21. 1 point
    its a comment should have // at beginning; This // assume all parts are same charset } // EMBEDDED MESSAGE the curly bracket at end is part of elseif condition should be // assume all parts are same charset } // EMBEDDED MESSAGE
  22. 1 point
    Here's an example of letting JavaScript do the work for you, once you give it required minimum data. NOTE: its not a good idea to have spacing in image file names, it tends to cause problems in coding, use underscore or hyphens instead. <!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> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <style> .mySlides {display:none} .demo {cursor:pointer} </style> </head> <body> <table width="1000px" align="center" border="1"> <tr> <td class="style_shop_text" colspan="3"> <a href="/shop/shop_prod1_menu_1.shtml"> <img alt="Product 1" src="/images/site/shop/prod1.jpg"> </a> </td> </tr> <div class="w3-content" style="max-width:1000px"> <tr> <td style="width: 333px" valign="top"> <P class="style_shop_text"></br> Product - £11</br></br> Dimensions : 5cm (approx)</br></br> BLAH BLAH BLAH</br> </P> </td> <td valign="top" align="center" valign="top" colspan="2"> <img class="mySlides" src="/images/work/prod 1-1.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 1-2.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 1-3.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 2-1.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 2-2.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 2-3.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 3-1.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 3-2.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 3-3.jpg" width="400" height="400" alt="Product 1"> <!-- <img class="mySlides" src="/images/work/prod 4-1.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 4-2.jpg" width="400" height="400" alt="Product 1"> <img class="mySlides" src="/images/work/prod 4-3.jpg" width="400" height="400" alt="Product 1">--> </td> </tr> <tr> <td> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="xxxxxxxxxxx"> <table> <tr> <td> <input type="hidden" name="on0" value="Product_combo"> </td> </tr> <tr> <td> <select name="os0" id="Product_combo"> <option value="Product 1-1" data-src='["prod 1-1", "prod 1-2", "prod 1-3"]'>Product 1 £11.00 GBP</option> <option value="Product 1-2" data-src='["prod 2-1", "prod 2-2", "prod 2-3"]'>Product 2 £11.00 GBP</option> <option value="Product 1-3" data-src='["prod 3-1", "prod 3-2", "prod 3-3"]'>Product 3 £11.00 GBP</option> <!-- <option value="Product 1-4" data-img-index="9" data-src1="/images/work/prod 4-1.jpg" data-src2="/images/work/prod 4-2.jpg" data-src3="/images/work/prod 4-3.jpg">Product 4 £11.00 GBP</option>--> </select> </td> </tr> </table> <input type="hidden" name="currency_code" value="GBP"> <!-- <input type="image" src="http://www.mywebsite.co.uk/images/site/button_add_to.jpg" border="0" name="submit" alt="PayPal – The safer, easier way to pay online."> <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">--> </form> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" > <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="xxxxxxxxxxxxxx"> <input type="hidden" name="display" value="1"> <!-- <input type="image" src="http://www.mywebsite.co.uk/images/site/button_view_cart.jpg" border="0" name="submit" alt="View Shopping basket"> <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">--> </form> </td> <div class="w3-row-padding w3-section"> <td colspan="2" valign="top"> <table width="100%" border="0" valign="top" id="imageTable"> <tr> <div class="w3-col s4" valign="top"> <td style="width:33%" align="center"> <img class="w3-opacity w3-hover-opacity-off" id="prod_menu_image_1" height="200" src="/images/work/prod 1-1.jpg" width="200" alt="Product" onclick="currentDiv(1)"> </td> </div> <div class="w3-col s4" valign="top"> <td style="width:33%" align="center"> <img class="w3-opacity w3-hover-opacity-off" id="prod_menu_image_2" height="200" src="/images/work/prod 1-2.jpg" width="200" alt="Product" onclick="currentDiv(2)"> </td> </div> <div class="w3-col s4" valign="top"> <td style="width:33%" align="center"> <img class="w3-opacity w3-hover-opacity-off" id="prod_menu_image_3" height="200" src="/images/work/prod 1-3.jpg" width="200" alt="Product" onclick="currentDiv(3)"> </td> </div> </tr> </table> </td> </div> <tr> <td colspan="3"> </BR> </td> </tr> </div> </table> <script> $("#Product_combo").on('change', function() { parentTable = document.getElementById("imageTable"); imgTag = parentTable.getElementsByTagName('img'); dataSrcArray = JSON.parse($(this).find(":selected").attr("data-src")); $.each(imgTag, function(key) { $(this).attr('src', "/images/work/" + dataSrcArray[key] + ".jpg"); }); var myslideElem = document.getElementsByClassName("mySlides"); $.each(myslideElem, function(indexkey) { $(this).css({"display": "none"}); myslideThis = $(this); $.each(imgTag, function() { if (myslideThis.attr('src') === decodeURIComponent($(this).attr('src'))) { $(this).attr("title", indexkey + 1); $(this).attr("onclick", "currentDiv(" + (indexkey + 1) + ")"); } if (decodeURIComponent(imgTag[0].src).indexOf(myslideThis.attr('src')) !== -1) { //imgTag[0].attr('src', myslideThis.src); myslideThis.css({"display": "block"}); } }); }); }); function plusDivs(n) { showDivs(slideIndex += n); } function currentDiv(n) { showDivs(slideIndex = n); } var slideIndex = 1; showDivs(slideIndex); function showDivs(n) { var i; var x = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("product_slides"); if (n > x.length) { slideIndex = 1; } if (n < 1) { slideIndex = x.length; } for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots.className = dots.className.replace("w3-opacity-off", ""); } x[slideIndex - 1].style.display = "block"; dots[slideIndex - 1].className += " w3-opacity-off"; } </script> </body> </html> Now could add extra custom data for image path, or add full image file name and path, (but it looks cleaner without the path) to data-src, up to you.
  23. 1 point
    A id identifier is singular and unique within a page, it is used to target one specific element only. A class identifier is the opposite it can be used multiple times within a page.
  24. 1 point
    You took away the hover class that causes the tooltip to appear. The visibility never changes.
  25. 1 point
    In your HTTPS page all the Javascript files should also be loaded with the HTTPS protocol because the browser does not allow loading unencrypted content on an encrypted page. This file on your page is still using unencrypted HTTP: http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
×