Jump to content


  • Posts

  • Joined

  • Last visited

Previous Fields

  • Languages
    Improving on HTML and CSS, Learning Javascript

SnakesBite101's Achievements


Newbie (1/7)



  1. I understand how Ternary operators work but i came across an inline one and im trying hard to figure out what each operation is doing. Can anyone please explain this to me: var hadRelations = false,isSure = false, presidentQuote = hadRelations ? "Did not have relations" : isSure ? "Did not have relations" : "I admit"; "I admit" is the value returned 1st i dont understand why they use "," instead of ";" to terminate variable definitions. But what is the Ternary doing? i don't understand the use of the first two strings in the operation. What is the concept here, what would make the return value equal to either of the first two strings, instead of the last one? Thanks
  2. thanks. ive caught so many random statements about html5 being able to do this and that, like programing etc.. and it started to scare me:( thanks for explaining it
  3. can i stop that happening by using max-height, max-width etc..? i used position relative or absolute. is fixed a better choice?ill definately not use those types of buttons again. just checking to see what i could do. ill start a new page and try and make it look a lot more readable and well thought out. thanks
  4. in your opinion could u please tell me which 1 is better to learn 1st. php or Javascript? also is learning HTML5 a lot harder to learn than 4?
  5. hey guys. W3schools has taught me everything i know. after HTML, they advised CSS, then Javascript. Even though i find JS hard, i believe i have past the beginner level, but still Im just not satisfied with my skill with JS yet. i have stalled. i don't believe im progressing anymore. w3schools advised PHP after JS. An old friend of mine said Javascript is better learned AFTER or with PHP but not by itself. He's reasoning is i need server stuff to work with. That if i learn JS alone, there are certain aspects of JS I won't be able to put into practise, it will just be memory knowledge i.e AJAX... that will eventually become impossible to progress. but if i learnt PHP, i will now be able to learn things like ajax and jQuery and put my knowledge of them into practical use, and not just remember what i read. I never thought learning php before JS was an option, or even together. My progress has stalled so i wonder if what he's saying is true, or is it too much to learn all of these things mentioned together?
  6. hey many thanks for explaining it to me. The code is definately a lot clearer for me now.
  7. Hey guys, i need a little help understanding cookies. I feel the cookie tutorial on the site was rather poorly explained. i'm trying really hard to make sense of it, i'm sure it's a small detail im missing. http://www.w3schools.../js_cookies.asp it starts off with this code: function setCookie(c_name,value,exdays){var exdate=new Date();exdate.setDate(exdate.getDate() + exdays);var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());document.cookie=c_name + "=" + c_value;} Most of this is clear, but can someone tell me what a cookie value is? They explained c_name as a visitors name. exdays as days until cookie expires. But c_value was never explained. niether was the ternary operator in the whole tutorial. i understand the operator but not in this context. what is escape(value)? this part is what really confuses me: function getCookie(c_name){var i,x,y,ARRcookies=document.cookie.split(";");for (i=0;i<ARRcookies.length;i++){x=ARRcookies.substr(0,ARRcookies.indexOf("="));y=ARRcookies.substr(ARRcookies.indexOf("=")+1);x=x.replace(/^\s+|\s+$/g,"");if (x==c_name){return unescape(y);}}} what is var i,x,y,ARRcookies=document.cookie.split(";");? and what object or string exactly is being split? Im guessing its the data from the previous function etc.. but the splitting and slicing of an array is very confusing as the actual string being split was never shown, so i have no idea what is being done. then i guess those are regular expressions at the end? its just so confusing. that whole code including the parts i didnt paste, was only explained with 9-10 lines. if you might not be able to explain this, could you please direct me to any sites that explains the coding of cookies in greater detail? Thanks all
  8. hey sorry i didnt see your last message. sure i would love some help to fix that issue. i havent even touched or modified the site since then as ive been just studying Javascript. With the bad design of the site, i probably won't touch it again, but it would be nice to know hot to fix the issue
  9. For instance i know Math.random() returns a random number between 0 and 1i know Math.floor(Math.random()*11) returns a random # between 0 and 10 but say i wanted the random number to start from 5 and not 0. how do i go about doing this?
  10. quick question. would this also solve the issue: if typeof obj !== null;
  11. ok thanks thats clear. i just tried it on firefox and it worked. thanks ill be double checking on 2 browsers from now on
  12. i have a question. i did a quick person array. ive used both a for and for in loop to loop through it. they give me the same results. If i alert the results, i get a separate alert for each element in my array. but if i use document.wrtie, my code only writes out the 1st element, "john". can anyone tell me why this is happening: <!DOCTYPE html><html><body><button onclick="myFunction()">Try it</button><script type="text/javascript">function myFunction(){var x;var person=["John","Pete","Ray"];for (x in person){document.write(person[x]);//alert works fine but not document.write}}</script></body></html>
  13. thanks guys. hey on 6) you are right. in my 1st post i said that the video is whats making me not complete the site. which is why i put the yellow border, bottom of the page container to show how that video went outside of it. the containers height is 100% so i dont know why this happened. margin and padding doesnt fix it. thank you for your points i will make all changes. very tough to spend time on the page because im trying to learn javascript, HTML5 and CSS3 at the same time:(
  • Create New...