JavaScript - Why Am I Learning Javascript?
So should I be learning javascript, what am I going to achieve by understanding this language?
My background: Designed a website for my wifes shop: http://www.eden-flowers.co.uk Enjoyed the html and css design side of things, then we decided to add a shoppping cart, to see if we could sell a few products online. Used opencart by the way, which I thought was a good free product and reasonably easy to implement. Having looked deeper into the opencart noticed that it used PHP, so I'm thinking I would like to understand this better. And here I am now trying to understand Javascript purely because I use w3schools alot for reference and their next logical step seemed to be Javascript. I'm rambling, but if you care to respond to this very open question, then pls feel free to voice your opinion/suggestions. Similar TutorialsCode: <HTML> <HEAD> <SCRIPT TYPE="text/javascript"> //Define Functions function student(name,age,mother) { this.name = name; this.age = age; this.mother = mother; this.displayProfile = displayProfile; } function grade(math,english,science) { this.math = math; this.english = english; this.science = science; } function displayProfile() { document.writeln("Name: " + this.name + "); document.writeln("Age: " + this.age + "); document.writeln("Mother's name: " + this.mother + "); document.writeln("Math Grade: " + this.grade.math + "); document.writeln("English Grade: " + this.grade.english + "); document.writeln("Science Grade: " + this.grade.science + "); } </SCRIPT> </HEAD> <BODY> <SCRIPT TYPE="text/javascript"> { student1 = new student("John",18,"Diane"); johngrade = new grade(100,80,90); student1.displayProfile(); } </SCRIPT> </BODY> </HTML> Alright, I am learning javascript and in the middle of experimenting with functions, I don't see why this does not work? In order to learn "cool" javascript such as rollovers that you find on websites today; what would any of you guys reccomend me doing. I want to learn how to make my webpage interactive and i know what i want to do; i just dont know how to do it any suggestions are welcome; thank you Hello everyone, I am currently going through the process of learning JavaScript and I am enjoying it. I also know enough about HTML & CSS and I am learning more and more each day. I started doing this because I figured that finding a technical co-founder is extremely hard and I have always been interested in web and app development, so why not learn... I was wonding whether someone could direct me? I want to be able to develop websites such as scan.me or gumroad.com (similar concepts). Which code stack are these websites generally made up of (e.g php, HTML CSS and java). I'm hoping to develop my own platform/concept in the future but I am just trying to get a general idea of the direction I am going down. Thanks, Paul Hi, I'm in the process of learning JavaScript. I picked up a "JavaScript for dummies" book at the library and it wasn't going too well. It was poorly written and made it difficult to understand things in the later chapter. What is the best online resource to learning JavaScript? Preferrably one that is good at explaining format ( I often find myself wondering if certain aspects in my script need ()'s or a "=" sign). For example, HTML has tags and that is what forms the mark up. I know JavaScript has multiple aspects (functions, objects), but I want an online resourcethat properly explains the format of these aspects. Thank you Hello all. I have been taking a JavaScript course on Udemy that while has been a very good course as far as I can tell, it has been short on practical exercises. Lots of examples, lots of showing different concepts and methods, etc, just short on the reinforcing and confidence building exercises. Thus, the point to my post here. I wish there were some kind of web developing club here locally but alas if you don't hunt, fish, drink or chew tobacco you are kind of left out, LOL. Well its not that bad, I make fun of it, but sometimes it seems so. At any rate, I'm looking for some kind of resource or something I can participate in that will help me use what I am learning and help me build some experience, etc. I want to get past the 'noob' stage as quickly as I can and as far as I know the quickest way to do that is to start coding even if its really simple stuff and working to more complicated coding. So, does anyone know of such resources? Thanks in advance for your time and help. Hi, as the title states, I'm trying to learn some basic javascript, more particularly, jQuery. I HATE having to "allow" active content to run on my IE browser. Is there a way to allow active content permanantly? Instead of having to click allow each time I refresh or reload my test pages? Also, IE keeps freezing or crashing when I run pages with scripts on them. Is this just my browser? or something to do with the active content permissions? Trying to google my questions, but no luck yet. I am currently trying to learn the <form> object. Now I have done some things within <form> like setting up text fields with submit buttons, etc.. But now on this part of the course it is showing properties I think, within the decleration of the <form> such as shown below Code: <FORM METHOD="POST" ACTION="/cgi-bin/correct.pl" onSubmit="return false;"> Could someone explain to me what that ACTION="/cgi-bin/corrct.pl" is for along with the onSubmit="return false;" ?? I'd like an explanation of the properties of <form> if you could please. Im trying to learn how to code but i'm not getting it can anyone help me with java? <3 -ButterFly<3 Hi all How should I be doing this? I am trying to 'learn' how to set more than one value in a cookie. Then get them back out. Obviously i'm on the wrong track. These are my 'test' values: Code: var val = document.getElementById("yrname").value; //peterPan var val1 = document.getElementById("password").value; //tinkerBell //send to create cookie factory createCookie("inbed", val + '~' + val1, "1"); Then from url : alert(cookie) I get: inbed=peterPan~tinkerBell So far so good (well what I expected anyway) now using this function I completely lose tinkerBell. she was inbed with peterPan. Code: function readCookie(name) //name is passed in { var cookies = document.cookie.split(/~/g); //split at ~ //alert(cookies); //results: //cookies: inbed=peterPan,tinkerBell //cookies[0]: mytestcookie=peterPan // cookies[1]: tinkerBell //the last sighting var arg = name + "="; for ( var c = 0; c < cookies.length; ++c ) //iterate through the cookie { var ck = cookies[c]; //cookie array into an var //alert(ck); //inbed=peterPan (no tinkerBell -- not what I expected! //basically i'm now lost!!! //I don't get what happened to tinkerBell . if ( ck.indexOf(arg) == 0 ) //if the array at the index of arg 'name=' equal to position 0. { var temp = ck.split(/=/); //split the cookie array at = //alert(temp); //inbed=peterPan //alert(temp[0]); //inbed //alert(temp[1]); //peterPan , return decodeURI(temp[1]) //bring back array 1 } } return ""; } help on how I should be doing this much appreciated LT Ok guys, i am starting from he http://www.javascriptkit.com/javatutors/primer5.shtml Code: <script type="text/javascript"> var example example=document.lastModified document.write("This page was last modified: "+example) </script> I am having trouble understanding an actual situation which may require the above coding, can anyone give an example please? Hi there! I'm obviously new to the forums here and don't really know if this is the right place to get help. I've made a small game in an HTA file using JavaScript and HTML (don't laugh, this was a serious learning project for me). The problem I'm having is that, after running the game for a while (having played, like to level 10 say), the HTA begins to slow down HORRIBLY. By level 10, it's almost unplayable... it takes like 3 seconds to register a button click. My messy code is below (yes, it's the entire game... I know it's huge). I don't really care that the math is horrible in calculating hit points and damage and whatnot. All I want to know is, why the hell does this slow down? Any help would be greatly appreciated. (obviously, rename the text file to .hta or .html to load it) I have no js experience or coding experience of any kind other than the last few hours of reading a book called 'object-oriented javascript', and all was well until loops. firstly, this is how he teaches the while loop... var i = 0; while (i <10) {i++;} which results in 9 we move on to for loops... var res =''; for( var i = 0; i <10; i++) {res += 'sometext' ;} which repeats, but I'd like to be able to make that into a sequence of numbers... 123456789. how do I do that? thanks. Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. I want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please |