JavaScript - Differences Between Programming Languages
Greeting Everyone,
Can anyone breakdown the differences between programming languages in VERY VERY BASIC plain English? (i.e. HTML use for website format, CSS used for the graphics on the webpage) Here's what I have questions about: 1. Differences between the most commonly used programming languages for software/web development (Javascript, Ruby on Rails, Phyton, etc.). 2. How do you determine which programming languages to use? 3. What factors are considered? Thank in advance for the people that reply. =) Similar Tutorialsplease i want to know if there is a possibility to force the user to type english characters coz i made all my web site in arabic and germany languages i want to force user to type the username and password in english characters any ideas? I want to have a browser language detection for 2 languages for Explorer and Firefox and struggle a little to make it work. I don't know really much about JavaScript so I guess I did some grave errors. It works for one language though, but for that I don't really detection. I am not sure if that's wrong, but I try to look for the 'en-' in the language not to deal separately with en-US, en-AU, en-UK etc. PHP Code: <script type="text/javascript"> var str=navigator.language; x = (str.search(/en-/i)); if ( !(x=='-1') ) { document.write("English Mozilla"); } var expl=navigator.browserLanguage; ex = (expl.search(/en-/i)); if ( !(ex=='-1') ) { document.write("Englisch1 Explorer"); } var dm=navigator.language; d1 = (dm.search(/de-/i)); if ( !(d1=='-1') ) { document.write("German Mozilla"); } var dex=navigator.browserLanguage; dexpl = (dex.search(/de-/i)); if ( !(dexpl=='-1') ) { document.write("German Explorer"); } </script> What are the differences between these? 1. Code: document.domain 2. Code: window.location.hostname 3. Code: self.document.location.hostname #1 and #2 I would think are very cloes, #3 would be if someone framed the site the script was on, it would show the framed site, and not the site that is framing? because of self. Hi, I wrote some javascript for a slideshow. The main webpage contains: Code: <FORM NAME="myform"> <IMG SRC="firstimage.jpg" NAME="mypic"><br> <INPUT TYPE="text" SIZE="180" NAME="mycaption" VALUE="First Caption"> <INPUT TYPE="button" VALUE="Prev" NAME="prevbutton" DISABLED=true ONCLICK="slideshowBack()"> <INPUT TYPE="button" VALUE="Next" NAME="nextbutton" ONCLICK="slideshowUp()"> </FORM> which assigns the image and caption for the first picture, and sets the Prev and Next buttons to disabled and not disabled respectively. So you start with the first image and caption, and an enabled "Next" button. I have global javascript variables: num (init to 1), max (init to 7), img1..7 (new Image ()), img1..7.src (filenames for the images), text1..7 (captions for the images), map1..7 (maps for the images). The function for moving to the next slide is: Code: function slideshowUp() { num=num+1 if (num==max+1) {num=1} document.mypic.src=eval("img"+num+".src") document.getElementById("mypic").useMap=eval("map"+num) document.myform.mycaption.value=eval("text"+num) document.getElementById("prevbutton").disabled=(num==1) document.getElementById("nextbutton").disabled=(num==max) } I developed this in HMTLPad (10.2) and it works perfectly in that program's preview mode. But it won't work in the main browsers! In IE 9 (9.0.33), when you click the Next button, nothing at all happens. Image and caption stay the same, Next stays enabled, Prev stays disabled. Maps don't work. Chrome (38.0.2125.122 m) and Firefox (27.0) behave like each other. The images change, but not the captions or the Prev/Next buttons. Maps don't work. Is this to be expected? If so, how do I work around it? Can someone explain to me the differences between the following code snippets? Mainly i don't understand the purpose of using prototype and not sure if there is a functional difference between the syntax of declaring functions. Code: var myObj = function () { this._myInt = 1; } myObj.prototype = { myNewFunction: function() { this._myInt = 2; } } VERSUS Code: var myObj = function () { this._myInt = 1; function myNewFunction(){ this._myInt = 2; } } Hi all, This is my first post of many and am new to JS. I'm familiar with Java so I shouldn't be too lost. What I'm about to do is add support for a web app from Firefox to IE that uses OpenLayers. I've searched and found a link to this site from another thread which had a list of supported functions and what not he http://www.quirksmode.org/dom/w3c_core.html From what I've read in the last hour it seems as though I will have to use some browser sniffing (isMozilla, isIE8, etc) and have multiple conditions (if-else's) in my functions to use the proper calls. Does anyone have extra material that contains differences between IE and firefox? Someone mentioned to me that in lists IE doesn't support trailing commas but ff does.. Things like this would be very helpful Thanks, Chris Hi I recently started researching about programming and was interested right away. I'm new to all this and need a place to start. Any help would be greatly appreciated and look forward to posting on this forum. I'm sure this is old news, but I am trying to use the CSS Horizonal List Menu script on JavascriptKit and having some display problems. http://www.javascriptkit.com/script/...stopmenu.shtml It works well except that I can't seem to get the CSS settings to display the same way in FF and IE. I can use pixel settings for the box size to get the menu across the entire screen in FF, but it only goes about 80% of the way in IE. If I maximize for IE, then the FF menu wraps. The % options for box size don't seem to work either. I am using Dreamweaver 4 for css settings. Is this just a limitation in the way the two browsers interpret the code? If there is an easy fix I could try it, otherwise I can live with what I have. I just need to know if there is some way to deal with it or not. If interested, the current version is at: www.chromafrica.com/template/template2.html. I'm trying to find the difference between 2 times. Time formats are 00:00:00.0 For example... var t1 = "00:07:51.0"; var t2 = "00:53:21.0"; How do I calculate the difference between those 2 times? TIA. Im having a problem with my Android applet I am creating using a program called Eclipse It reads the error: 'The method onCreateOptionsMenu(Menu) in the type Activity is not applicable for the arguments (Menu)'. Here is what I have written: [code] public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater awesome = getMenuInflater(); awesome.inflate(R.menu.main_menu, menu); return true; } [code] Problem: When I click the compute button, it does not do anything. It does not go to function CALCULATE and do its stuff . Please help me. This is my PHP code. Code: echo "<table border=1>"; while($row_contestant<$numrows_criteria) { $CId=mysql_result($result_contestants,$row_contestant,"CId"); $CName=mysql_result($result_contestants,$row_contestant,"CName"); echo "<tr><td width = '10'>$CId</td><td>$CName</td>"; for($start2 = 1;$start2 <= $counter;$start2++) { echo "<td><input type = 'text' name = 'cr[]' value = ''></td>"; } $row_contestant++; echo "<td><input type = 'text' name = 'rating' value = ''></td><td><input type = 'Button' name = 'getAvg' value = 'compute' onClick = calculate()></td></tr>"; } echo "</table> <p>"; } This is my Javascript calculate function code Code: function calculate() { sum = 0; for(i = 0;i<=Number(document.frmOne.counter.value);i++) { sum = sum + Number(document.frmOne.cr[i].value) } document.frmOne.rating.value = sum } The output: Any help would be highly appreciated. God Bless. IndyNS I am trying to create a dynamic form on my webpage. What I want to do is repeat this process multiple times on the same page. I know I have to have unique id's but I am not for sure how to set them. // JavaScript Document function addRowToTable(){ var tbl = document.getElementById('Division'); var lastRow = tbl.rows.length; // if there's no header row in the table, then iteration = lastRow + 1 var iteration = lastRow; // var iteration = lastRow + 1; var row = tbl.insertRow(lastRow); // cell 0 var cell0 = row.insertCell(0); var el = document.createElement('input'); el.type = 'text'; el.NAME = 'Resource[]'; el.size = 30; cell0.appendChild(el); //cell 1 var cell1 = row.insertCell(1); var el = document.createElement("select"); cell1.innerHTML + '<option value="0">Avaliable</option>' + '<option value="1">Busy</option>' //cell 2 var cell2 = row.insertCell(2); var el = document.createElement('input'); el.type = 'text'; el.NAME = 'Comment[]'; el.size = 25; cell2.appendChild(el); } hi every one i;m new here and i love to know programming languages and some friends adviced me to start with java script then php , and i guess i'm at the right place can you please tell how to start and where to begain i'm really don't know anything about programming
The following code results in the exact same output. Is there an advantage to using i++ over ++i (or visa-versa) in the loop? Code: <script type="text/javascript"> var tarr1 = []; for (var i=0; i<10; i++) { tarr1.push(i); } var tarr2 = []; for (var i=0; i<10; ++i) { tarr2.push(i); } alert(tarr1.join(',')+'\n'+tarr2.join(',')); </script> Similar question for the increment method in the following: Code: <script type="text/javascript"> var tarr1 = []; var i=0; do { tarr1.push(i); i++; } while (i<10); var tarr2 = []; var j=0; do { tarr2.push(j); ++j; } while (j<10); alert(tarr1.join(',')+'\n'+tarr2.join(',')); </script> Hello, As a novice, I'm not sure which one to use though. I'm trying to do a calculation with numbers in JavaScript using variables, particularly adding variables. Any guided understanding of this concept is welcome. For example: Code: n = parseint(n) document.write(n += m) A week or so ago Old Pedant and I discussed methods of converting string inputs to numbers. I speculated that *1 might be quicker. I have now run a test:- Code: <script type = "text/javascript"> var start = new Date().getTime(); for (var i =0; i <100000; i++) { var a = "2"; a = a *1; } var end = new Date().getTime(); var diff1 = end - start; alert (diff1); // 109 var start = new Date().getTime(); for (var i =0; i <100000; i++) { var a = "2"; a = parseInt(a); } var end = new Date().getTime(); var diff2 = end - start; alert (diff2); // 140 var start = new Date().getTime(); for (var i =0; i <100000; i++) { var a = "2"; a =Number(a); } var end = new Date().getTime(); var diff3 = end - start; alert (diff3); // 140 var start = new Date().getTime(); for (var i =0; i <100000; i++) { var a = "2"; a = +a; } var end = new Date().getTime(); var diff4 = end - start; alert (diff4); // 109 </script> The results vary slightly with each run, but the conclusion is that there is no real difference between the methods - except for a = a*1 and a = +a which consistently comes in lower than parseInt() or Number(). But the differences are too small to be significant. I have searched all over for tutorials on multiplayer game programming. I cannot seem to find anything relevant to my question, though. I don't even think that I can use javascript, but as I said, I do not know where to start. All I want, for now, is to make something simple like tic-tac-toe or rock-paper-scissors, which will be played by two users on two machines. Then once I've gotten that, I can move onto making something more in depth. Any push in the right direction is greatly appreciated! -Shane Okay so if you go to this website: http://gameusd.com/ You can pick your game & country -- say its world of warcraft US And then you pick your realm and faction, and then it gives you the prices on those particular realms/factions. What i wanted to know was if it was possible to somehow make a program that fetches the prices of EVERY single realm/faction and lists them all side by side and in order of lowest to highest price or whatever. Would massively appreciate if somehow could tell me if its possible. Because obviously doing it all manually would be a huge pain in the *** and take hours. Hi everyone-- I am a fourth grade teacher and I have an idea for a program I could use with my students. I think (key word, I don't know anything about programming) that it should be relatively simple to do. A short description of what the program would do will follow, but my posting is for three main reasons: 1) Is this possible? (I assume it is) 2) As I would be willing to pay for this (up to a certain amount), how much might it cost me if I hired a freelance programmer? 3) Is there anyone out there who would be able to help me with this? Okay, as for the program: it would be a program that would make your own "Jack Attack" (like from the computer game "You Don't Know Jack"). It would give you a place to input up to 10 to 15 keywords (or vocabulary definitions) for the middle and keywords (or vocab words) that would fly past. It would respond to some sort of button input (I'm thinking space bar)....and have an action for wrong answers (buzzer sound) and an action for a right answer (ding! and then move on to next question). Maybe after the game it would give a readout of how many right out of how many possible. It would be really cool to be able to have some background music, maybe manipulate the the colors, fonts, etc. I am wanting to leave the program kind of generic so that I could use this for all sorts of applications: use it for vocabulary words in different subjects, match authors with books, "just for fun" games, maybe even use it for some math facts. Any information you would have is more than appreciated! Thanks for helping a teacher out! Clay |