Jump to content

spence911

Members
  • Content Count

    38
  • Joined

  • Last visited

Community Reputation

0 Neutral

About spence911

  • Rank
    Member
  • Birthday 09/24/1997

Profile Information

  • Gender
    Male
  1. I can't find an explicit answer on this anywhere, but when you create a child class from an abstract class must you use ALL of the methods that are inside the abstract class in the new child class? Or are these methods just available to the child class to pick and choose?
  2. spence911

    What is PDO::PARAM_INT;

    Just figured this out. Its a constant that ensures that the data returned is an integer(TINYINT, MEDIUMINT, BIGINT...) so that PDO can pass the correct data type to MySQL. PDO will also escape any quotes and other characters thereby preventing SQL injection.
  3. spence911

    What is PDO::PARAM_INT;

    What's up guys! Can somebody please explain the meaning of PDO::PARAM_INT in the following statement: $pdoStmt->bindValue(":num", $num, PDO::PARAM_INT); I have already created a PDO Statement object called $pdoStmt. This line will bind the value of $num to the placeholder called :num. I know that PDO::PARAM_INT is a Predefined Constant but what does it do in this case? Thanx
  4. spence911

    JavaScript closures

    Thanks for the workaround. So if I understand correctly, the value of links is undefined because once the for loop has finished executing, whatever new value the for loop has created for var links is thrown out and replaced by the original value which is var links = document.links; correct?
  5. spence911

    JavaScript closures

    Whats up guys. I've created two links in an html document. The problem is the JavaScript below gives me a value of undefined after running the for loop. I know this has something to do with closures, which I don't have much experience with so I can't figure out why the value of links is undefined. JavaScript: window.onload = function getLinks(){ var links = document.links; for(var i = 0, count = links.length; i < count; i++){ links[i].onclick = function(){ alert(links[i].href); return false; }; } }; html: <body> <p><a href="linkOne.html" id="link" target="linkOne">Link B</a></p> <p><a href="linkTwo.html" id="link" target="linkTwo">Link A</a></p> <script src="js/handleLinks.js"></script> </body> </html>
  6. spence911

    JavaScript Error Handling - try, catch, finally

    Thanks a lot. That I know. But why does removing the catch block affect the very last line: document.write( "Back to safety." ); That last line will only execute if the catch block is not omitted out.
  7. Hi guys! I would really appreciate it if somebody could explain to me why in the code below the last line "document.write( "Back to safety." );" will only execute if the catch block is not commented out. In other words, the script below will output "Finally!". But if the catch block is not commented out, the output is "Caught your error:someFunction is not definedFinally!Back to safety." <head> <title>Title Time! Yeah</title> <script type="text/javascript"> try { // Throw an error so the catch is triggered. nonExistentFunction(); } /*catch( error ){ // Catch the error. document.write( "Caught your error:", error.message ); } */ finally { document.write( "Finally!" ); } // We got past our try/catch. document.write( "Back to safety." ); </script> </head> <body> </body> </html>
  8. spence911

    JavaScript createTextNode

    Thanks denno020. I created a <p> container with the id of output and added this at the top of the function: document.getElementById('output').innerHtml = '';. But I'm still getting an error messages on every click instead of just one. html: <body> <div><label for="firstName">First Name</label> <input type="text" name="firstName" id="firstName" value="First Name"/></div> <input type="button" name="btn" id="btn" value="Submit"/> <p id="output"></p> <script src="js/validayt.js"></script> </body> </html> js: window.onload = function(){ 'use strict'; document.getElementById('btn').onclick = function(){ document.getElementById('output').innerHtml = ''; if(document.getElementById('firstName').value == document.getElementById('firstName').defaultValue){ var msg = document.createTextNode('Incorrect information.'); document.getElementById('output').appendChild(msg); } }; };
  9. spence911

    JavaScript createTextNode

    I'm using JavaScript to validate a form field. Basically, if the form is submitted and the default value of the field is not altered, a text node with an error message will be generated. Problem is if the submit button is clicked over and over, the error message will appear just as many times as the button is clicked, ie. Incorrect information.Incorrect information.Incorrect information.Incorrect information. How do I make the generated message appear only on the first button submit. I tried this but it JavaScript: window.onload = function(){ 'use strict'; var errorMsg = 'Incorrect information.'; document.getElementById('btn').onclick = function(){ if(document.getElementById('btn').value == document.getElementById('btn').defaultValue){ var msg = document.createTextNode(msg); document.getElementById('btn').parentNode.appendChild(msg); /* This if statement didn't work if(msg){ document.getElementById('btn').parentNode.replaceChild(msg); }*/ } }; }; html: <body> <form action="#" method="POST" id="theForm"> <div><input type="text" name="firstName" id="firstName" value="First Name"/></div> <input type="button" name="btn" id="btn" value="Submit Info"/> </form> <script src="js/validate.js"></script> </body> </html>
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.