Jump to content


  • Posts

  • Joined

  • Last visited

About nhuyvan1106

  • Birthday 06/11/1992

nhuyvan1106's Achievements


Newbie (1/7)



  1. Hi yo, same here, I just didn't discover the deep PASSION for programming after I got fired from Amazon( , I am really glad that happened even though I was really depressed, if it had not, it would have followed the auto mechanic path which would be very different), but anyway, I had the same questions as you do also, and I am just 23 like you are too , I started out with HTML, CSS, then JS, but that is not enough though, I am now teaching myself java (and android programming) which is really frustrating to learn yourself, but like I said, PASSION, it helps me overcome my frustration(I even hit my head many times for being so stupid ), anyway, let me tell you, web developers, software developers, etc... are the most well-paid technology-related jobs ever(You can google). To develop websites, HTML, CSS, and JS are the must-learns, besides that, you should learn some server-side programming language, for example Java which is what I am learning right now, you can choose other languages as well, but Java is really great when you learn it, many people hate it, and call it verbose(but hey, people always have something to hate on) but I think Java is a bit easier to learn than C++, trust me, when you look at C++'s data types(which is the first thing you'll learn for every language), you'll hate it, it is just redundant, because C++ is platform-dependent, I do hate it ALOT, and Java is platform-independent(Probably the only one that is as far as I know) and many other features especially those APIs or class libraries(which are code written by other people you can use, people at SunMicrosystem often say "We do this, so you don't have RE-INVENT THE WHEEL"), there's a saying about Java "Write once, run anywhere", but what I said doesn't make learning Java a piece of cake, there's alot to it just like other languages, anyway, you need to know server-side programming also to create sophisticated, beautiful applications that can do stuff for a website, JS is mostly for client-side programming, I just want to give one advice, very good one, when you become frustrated and want to quit(which I have never thought of even), it is never easy when you learn something on your own, so think about the day that you have become successful with what you learn, making a very good living doing it, it will keep you motivated ALOT, and that is what I am doing to motivate myself, and it just excites me every time, and one final word, thank you Amazon for firing me haha. Sorry for the long response.
  2. Oh yeah, mannnnnnnnnn, that makes alot of sense, because setInterval() doesn't cancel itself out like setTimeout() does, so it will keep calling itself multiple times during 1-second interval really lightning-fast, that is why the number appears to be skipping over, man, thanks alot for saving me a headache.
  3. <!DOCTYPE hmtl><html lang = "en-US"> <head> <meta charset = "UTF-8"> <script type = "text/javascript"> window.onload = myFunction; var i = 11; function myFunction() { document.getElementById("output").innerHTML = display(); setTimeout(myFunction, 1000); } function display() { i--; var prompting; if (i == 0) { i = 10; prompting = confirm("Do you want to go?"); if (prompting == true) { window.location = "http://www.google.com"; } } return "You will be re-directed in " + i; } </script> </head> <body> <div id = "output"></div> </body></html> Hi guys, I just made this little countdown clock, but one thing is really confusing me, the setTimeout() function up there, it works fine, but whenever I replace it with setInterval(), the variable i doesn't step down by every 1 unit at all, instead, it goes like, 9 ....7....3, but when I use setTimeout(), it goes 10..9..8.. till 0. You guys know why? Thank you very much.
  4. Thank you Don. Yes, I have thought about that, but it is too superfluous. Ingolme's idea is really awesome. That's what I was trying to look for. Excellent. Thank you so very much guys. Your help and time are not forgotten.
  5. <!DOCTYPE html><html lang = "en-US"> <head> <meta charset = "UTF-8"> <style type = "text/css"> fieldset { width: 850px; margin: auto; text-align: center; } #txtField { text-align: center; } #tryAgainBtn { display: none; } </style> <script type = "text/javascript"> window.onload = myFunction; var randomNumber; var outPut; function myFunction() { randomNumber = Math.floor(Math.random()*1000); document.getElementById("checkBtn").onclick = checkAnswer; document.getElementById("tryAgainBtn").onclick = tryAgain; } function checkAnswer() { outPut = document.getElementById("outPut"); outPut.innerHTML = ""; var myInput = document.getElementById("txtField"); if (myInput.value < 0 || myInput.value > 1000) { return outPut.innerHTML += "I said between 0 and 1000."; } if (myInput.value == "") { return outPut.innerHTML += "Please enter a number between 0 and 1000!!!"; } if (myInput.value > randomNumber) { outPut.innerHTML += "Too High !!!"; } if (myInput.value < randomNumber) { outPut.innerHTML += "Too low !!!"; } if (myInput.value == randomNumber) { outPut.innerHTML += "Yay, you are awesome !!!"; document.getElementById("tryAgainBtn").style.display = "inline"; } document.getElementById("txtField").onclick = reset(); } function tryAgain() { document.getElementById("txtField").value = ""; outPut.innerHTML = ""; document.getElementById("tryAgainBtn").style.display = "none"; randomNumber = Math.floor(Math.random()*1000); } </script> </head> [attachment=1390:MyGame.png]<body> <form action = " " id = "myForm"> <fieldset> <p>Let's play a guessing game, I am thinking about a number between 0 and 1000. Enter your guess in the box, I'll tell you if it's correct or not. </p> <div id = "outPut"> </div> <input type = "text" id = "txtField"/> <br/> <button type = "button" id = "checkBtn"> Check your guess!!! </button> <br/> <button type = "button" id = "tryAgainBtn"> Try again ??? </button> </fieldset> </form> </body></html> Hi guys, I am building this text-based guessing game(please don't judge, I'm just a starter), everything is working correctly, just one thing I can't find the answer anywhere at all, but I sure know you guys do know the answer, my question is, btw, I've attached a picture so you can conjure up what I am trying to say, ok, so, after the user entered a value, and they are gonna enter another value, so when the user clicks on the box, what do I do to make the previously entered value removed, like when they click on the box, the previous value disappears, I've tried using the reset() method as you can see in the code, but every time the "Check your answer" button is clicked, the value disappears right away, and that is not I want, I really don't know method to use? any suggestions are greatly appreciated. Thank you very much for your time and help.
  6. <html><head><script type="text/javascript"> function showPosition() { var oElement = document.all.oCell; var myDiv = document.all.myDiv; alert("The span element is at (" + oElement.offsetLeft + "," + oElement.offsetTop + ")n" + "The offset parent is " + oElement.offsetParent.tagName + " offsetHeight is " + oElement.clientHeight); } </script></head><body onload="showPosition()"><div id = "myDiv" style = "width: 100px; padding: 10px 20px; position: relative; border: 1px solid black;float: right;"> <span id="oCell">This is a small table.</span> </div></body></html> Hi guys, I was messing around with the offsetSomething and clientHeight properties(experimenting with them actually), I noticed that clientHeight always returned "0" on that span element, when I changed to offsetHeight, it returned a value other than "0", BUT when set "style = 'display:block' " on that <span> element, clientHeight returned some value other than "0", and everytime I removed "style = 'display: block;' ", clientHeight returned "0", so clientHeight property only works on block-level elements or am I doing something wrong here? Thank you in advance guys.
  7. Hi guys, I just have a dumb question but looks like I can't find the answer anywhere at all. What is a global function? specifically, how do I determine the scope of a function? I know the definition of the variable scope, but function scope, I don't, hope you guys could clarify this for me. One more thing. I have this code down below about the "this" keyword. Doesn't the "this" keyword refer to the element that triggers the event? if so, why it pops up "undefined" when I click on the paragraph? I'm pretty positive "this" in my case is bound to a global variable(that's why it gives me an "undefined" id) which is the window object, but I don't understand why "this" is not referring to the "<p>" element at all. Any tips and hints are greatly appreciated brothers(Please take it easy on me if I sound dumb, I just started teaching myself JS a couple weeks ago or so, so) Thank you very much guys. <!DOCTYPE html><html><head><script>function myFunction(){ alert(this.id);}</script></head><body><p id = "myPa" onclick="myFunction()">This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p></body></html>
  8. Ah, ah, after hours of fiddling with this, finally got this figured out , hard work always pays off as always feeling so amazing, thanks a bunch guys.
  9. <!DOCTYPE html><html><head><script>function myFunction(e){ alert(e.target.id);}</script></head><body><p id = "myBody" onclick="myFunction()">Click on a paragraph. An alert box will alert the element that triggered the event.</p><p><strong>Note:</strong> The target property returns the element that triggered the event, and not necessarily the eventlistener's element.</p></body></html> I attempted to do this as you can see, but the handler won't do anything, what am I still missing here guys? Thank you
  10. <!DOCTYPE html><html><head><script>function myFunction(e){ alert(e.target);}</script></head><body onclick="myFunction(event)"><p>Click on a paragraph. An alert box will alert the element that triggered the event.</p><p><strong>Note:</strong> The target property returns the element that triggered the event, and not necessarily the eventlistener's element.</p></body></html> Hi guys, I am really struggling with this right now, please help. As you can see the above, I don't really understand these lines of code <body onclick="myFunction(event)">, and function myFunction(e) {alert(e.target);} what do "event" and "e" do, I know they are parameters which I can use whatever I like, my question is, why do I need "event" and "e" parameters here, and why are they so important? Second question, this line <body onclick="myFunction(event)">, I don't really know what the difference between <body onclick="myFunction(event)"> and <body onclick = myFunction>(without parenthesis and quotes). Thanks a bunch guys.
  11. Man, that makes alot of sense. It is hard sometimes when you are teaching yourself something, Im glad I found this forum and website. Thank you very very much Foxy mod, you don't know how much I appreciate the help, god bless you. Cheers
  • Create New...