Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. According to references, the value attribute should work on the <select> element as well. From MDN: Just with the information provided in this topic I can't understand why it's not working. Try to find out what this is referring to: sel.onchange = function() { console.log(this); console.log(this.value); // var show = document.getElementById('show'); // show.innerHTML = this.value;} In most browsers you can check the Javascript console by opening the developer tools using F12. See what's written in the console. Perhaps "this" is not referring to the right object for some reason.
  2. Here are the differences between your script and the example I gave you; Your script var show = document.getElementById('show');show.innerHTML = this.value; My example var select = document.getElementById("mySelectElement"); // It could be select = this if you wantvar index = select.selectedIndex;var option = select.options[index];alert(option.value); What you're doing is try to read a value property on the <select> element. What I'm doing is finding the <option> element that's currently selected and reading its value property.
  3. You could have put your code in the post, I'll put it here for easier reading: OnRecord if (isset($_POST['id'])){[glo_ProductID] = $_POST['id'];}if (isset($_POST['name'])){[glo_ProductName] = $_POST['name'];}if (isset($_POST['supplier'])){[glo_SupplierID] = $_POST['supplier'];}if (isset($_POST['category'])){[glo_CategoryID] = $_POST['category'];}if (isset($_POST['company'])){[glo_CompanyID] = $_POST['company'];}if (isset($_POST['price'])){[glo_UnitPrice] = $_POST['price'];}if (isset($_POST['quantity'])){[glo_QuantityRow] = $_POST['quantity'];}{col}= "<input type='text' size='6' onchange='myfunction("{ProductID}","{ProductName}","{SupplierID}","{CategoryID}","{CompanyID}","{UnitPrice}", this.value)'>"; OnHeader echo '<script>function myfunction(id, name, supplier, category, company, price, quantity){var xmlhttp;if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}else{// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhttp.status==200){console.log(xmlhttp.responseText);}}xmlhttp.open("POST",location.href,true);xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttp.send("id="+id+"&name="+name+"&supplier="+s upplier+"&category="+category+"&company="+company+ "&price="+price+"&quantity="+quantity.toString ());</script>'; Is this your real code? You have a few syntax errors. In your PHP, you seem to have substituted variables with square brackets [glo_ProductName] or curly brackets {col}. This isn't PHP syntax. In your Javascript, you have a syntax error right here: "+s upplier+"
  4. Did you read my previous post? I even provided some code on how to extract the value of the <select> element. Like I said: You have to target the <option> element that's selected and get its value.
  5. I don't know what's inside capquery.php so I don't fully understand what your code does. The reason it runs faster is because you're not making any extra HTTP requests. jQuery's load() method send an HTTP request, you were calling the load() method eight times. HTTP requests are a slow operation. Each request has to open, send data and close. Most browsers have a limit of two requests to the same domain at the same time, so a new request is not sent until previous ones are finished.
  6. That's a whole lot of HTTP requests you're making at the same time. Why don't you want to use PHP?
  7. Like with any user input, if you're going to print it out you need to make sure that it doesn't change the page's HTML code. It's no less secure than $_GET or $_POST.
  8. Blocking access to certain files is actually an important security measure. Hiding a file extension, not so much. Security through obscurity is not real security.
  9. I don't believe URL rewriting is a required layer of security. URL rewriting is just for easier to read URLs. Security should be properly handled in the code. You can use .htaccess to forbid access to particular files that are not meant to be opened in the browser, but not with URL rewriting, you would use the Allow / Deny directives for that.
  10. Ingolme

    UTC+0 time set

    I did the subtraction in the wrong order. It should be $t - time(); But your Javascript countdown script doesn't need to be given minutes, hours and days. It should generate them based on the timestamp. <?php$t = strtotime('Friday 18:30');$seconds_until_t = $t - time();?><script>// How long until the end of the countdown in millisecondsvar remainingTime = <?php echo $seconds_until_t * 1000; ?>;// Determine when the end of the countdown isvar targetTime = (new Date()).getTime() + remainingTime;// Execute this periodically using setTimeout or setIntervalfunction updateTimer() { var remainingTime = targetTime - (new Date()).getTime(); // 86400000 is the number of milliseconds in a day // We don't want the decimal part, so we floor it var days = Math.floor(remainingTime / 86400000); // Remove days from the amount remainingTime %= 86400000; // 3600000 is the number of milliseconds in an hour var hours = Math.floor(remainingTime / 3600000); // Remove hours from the amount remainingTime %= 3600000; // 60000 is the number of milliseconds in a minute var minutes = Math.floor(remainingTime / 60000); // Remove minutes from the amount remainingTime %= 60000; // 1000 milliseconds are in a second var seconds = Math.floor(remainingTime / 1000); // Now lets generate the time string and put it in an element var str = days + "days " + hours + "h " + minutes + "m " + seconds + "s"; document.getElementById("countdown").innerHTML = str;}</script>
  11. Ingolme

    UTC+0 time set

    In that case, Javascript does not need to know the date and time, it only needs to know how many milliseconds are remaining until the specified date and time. This will prevent the user's computer clock from causing problems. You haven't specified, but I assume when you say Friday 18:30 you mean the closest Friday to now and not some random date next year. You can use PHP's strtotime() function to get dates relative to right now. Here's how you can get the amount of time remaining until your target date and how to pass it to Javascript so that it can display a countdown: <?php$t = strtotime('Friday 18:30');$seconds_until_t = time() - $t;?><script>var remainingTime = <?php echo $seconds_until_t * 1000; ?>;// Use the remainingTime timestamp in your countdown script////</script>
  12. Make a global variable, let's say index. var index = 0; In your rotate function, show the element at index index, then add 1 to index. To ensure that the variable index is within the bounds of the array we can use the % (remainder of division) operator. function rotate() { // This is your other function which doesn't need to be changed add(index); // Add 1 to index index++; // Same as index = index % arr.length; index %= arr.length;}
  13. Ingolme

    Simplify URL

    You can search for URL rewriting. How it's done depends on what software is running on your server and how it's configured. Many servers use Apache in which you can use mod_rewrite directives in a .htaccess file in order to change the URL. It's not easy, you have to be willing to learn something new.
  14. You'll need a mouseover event handler on the links, but not a mouseout event. When the mouse is put over the link it should hide all the panels and then show the one that's associated to the link. You'll need a closing button on the panel that needs to be clicked on to close it. This will prevent the problem of dead space. In order to associate the link with one of the panels, give the panel an ID attribute, then use an HTML5 data attribute on the link that refers to the ID of the panel it's associated to. Then you can use that information in the event handler of the link to refer to the panel.
  15. Set text-align to center on the element that contains the buttons.( #first in this case)
  16. I don't understand. Does Microsoft Flight Simulator use HTML and Javascript?
  17. That will fix the apostrophe problem but then it will cause a problem when your XML values have " in them. You have to replace the ' and " with HTML entities ' and "
  18. Sure it can be done, but it would be a bad idea. It's difficult to read and maintain that kind of code. document.getElementById("FREQO").innerHTML = (document.getElementById("FREQB").value*100-10000).toString(8);
  19. In most browsers you can press F12 to open developer tools. Error messages are shown there which you can use to figure out why something is not working.
  20. Javascript is case sensitive. You've named your function freq() but you're trying to call FREQ() To drop two decimal places you need to multiply by 100.
  21. You can look into libraries to do what you want. The particular design you're going for is a ser of columns. To make columns, you create a series of containers, it can be a <div> element but if you can find a more semantically appropriate element (<section>, <article>) it would be better. The containers would have a percentage width, with percentage left and right margins. You can put other containers inside each column. There's a Javascript library called masonry.js (search for it) which will organize boxes for you on your page as well. As for letting users register, search for content management systems (CMS). It would take you many many years of learning and months of work if you were to try to make a content management system from scratch.
  22. It's better if you learn PHP first. The PHP tutorial explains how to use PHP to communicate with an SQL server, using SQL to manage the information.
  23. Learn HTML and CSS first. Don't move on to anything else until you understand them properly. People who code in HTML without knowing CSS end up making really bad HTML. The important thing to understand is that you don't use HTML to make things look pretty, write the HTML to describe the content that is within the tags. Later on you can use CSS to put things in their place. After you're proficient in HTML and CSS you can learn Javascript and PHP. The order in which you learn them does not matter much. While learning PHP you'll encounter SQL examples. I have no idea how long it takes on average to learn web development. I've been 10 years at it and still learn new things these days, there was no specific moment when I suddenly changed from beginner to expert. I can guess that one year is probably enough to get you started for an entry level job if you dedicate yourself to it, after that you must continue to dedicate yourself to it and keep learning all the time. Read reference manuals, look for things you still don't understand and find the answers. If you've never looked at coding before in your life it might take you a while to understand it. It takes time to adapt to a new way of thinking.
  24. Ingolme

    UTC+0 time set

    Then don't use Javascript for it. Javascript dates are taken from the user's computer and can be wrong. PHP takes its dates from the server, why would you need Javascript to pass information to PHP when PHP can get the information more accurately itself? Where is the source of this information? You said you want a day of the week and the time, which day of the week do you want? Here's how to get a date in UTC from PHP: // Assuming you want the day of the week and time for right this moment$now = time();$weekday = gmdate('N', $now);$time = gmdate('G:i', $now);// Do whatever you want with the $weekday and $time variables
  25. The <a> element is inline and that's the one you're putting the border on. What you want to do is put the border on a block element. You can turn your <a> element into an inline-block. You can't use negative values for padding. If you want to make the box even less tall then you'll have to set the height or line-height to a small value. Drop the :link selector, because if you don't then all the styles you set will vanish when the mouse hovers over the link.
×
×
  • Create New...