JavaScript - If You've Ever Struggled With Oo Programming In Javascript, Here's Enlightenment!
I have traditionally stayed away from javascript because until relatively recently, the lack of decent documentation has made me want to smash the computer in complete frustration!!
Now, I have found this little (seemingly quite new) gem which has, for the first time, explained javascript OO programming to me in five minutes flat, and I understand it perfectly!! It's not hard ... it's really not that hard ... but so many people on the net make such a hash of trying to explain it. Thank you Mozilla: https://developer.mozilla.org/en-US/...ted_JavaScript Similar TutorialsIndyNS 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); } Hello all, I am having some trouble getting my Javascript code to work properly. I want to create a program that allows two objects to race to a certain point which is 1000px in my program. I have figured out how to get the images to race at random speed, and I have figured out a function to reset the program if the user chooses to restart. Basically I can't figure out how to get the clearTimeout() to stop the Race() function when it reaches 1000px. I am fairly new to the Javascript world and could really use some suggestions or a point in the right direction. Thanks in advance, AJ. Here is my program so far: <body> <script language="JavaScript" type="text/javascript"> <!-- function StartUp() { if ((car1.style.pixelLeft<1000) && (car2.style.pixelLeft<1000)) { Race(); } else { alert(); } } function Race() { car1.style.pixelLeft+=(Math.floor(Math.random()*11)); car2.style.pixelLeft+=(Math.floor(Math.random()*11)); stop=setTimeout("Race()",50); } function Restart() { clearTimeout(stop); car1.style.pixelLeft=10; car2.style.pixelLeft=10; } function swapImage() { var image = document.getElementById("imageToSwap"); var length = document.getElementById("Road"); image.src = Road.value; } //--> </script> <div id="car1" style="position:absolute; top: 10"> <img src="Car1.gif" alt=""/> </div> <div id="car2" style="position:absolute; top: 75"> <img src="Car2.gif" alt=""/> </div> <img id="imageToSwap" src="Road1000.gif" alt=""/> <form name="form1"> <br> <input type="button" value="Race" onClick="StartUp()"> <input type="button" value="Restart" onClick="Restart()"> <br> Track Length: <select id="Road" name="Road" onChange="swapImage()"> <option value="Road1000.gif">1000 feet</option> <option value="Road750.gif">750 feet</option> <option value="Road500.gif">500 feet</option> <option value="Road250.gif">250 feet</option> </select> </form> </body> Hi so i am using onClick="myPopup(); on a button and when someone clicks on the button, it pops up an advertisement in a new tab. But is there a way to make the users stay on the page where the button is located instead of forcing the browser to automatically switch to the advertisement tab when a button is clicked? Friend i concern with some that man told me , JavaScript programming is the best effective for website development. so how it is tell me ?
I need to know two things. How do you position an alert or prompt to anywhere on the screen. How do you change the font for the alert or prompt (i.e Hebrew) Thanks in advance D.A. I have to take more javascript programming classes and I'm really not good at it. I desperately need help. I own Visual Basic, but it's a little difficult to use. What is the best book, online resource, and software for programming in javascript?
Hi All, I m newbie on JavaScript Coding. I have Form where the there are 4 radio buttons. Requirement is OnClick of Each radio buttons, some Div must Greyed out. <input type="radio" name="cf_basic_type" value="Apartment" checked="checked" />Apartment <input type="radio" name="cf_basic_type" value="Villa" />Villa <input type="radio" name="cf_basic_type" value="Independant" />Independant house <input type="radio" name="cf_basic_type" value="Plot" />Plot</div> and Grey Part of Form is: Area Size:<input type="text" name="cf_area_size" id="cf_area_size" /></div> Plot Size:<input type="text" name="cf_area_length" id="cf_area_length" /> <input type="text" name="cf_area_width" id="cf_area_width" /> so for Plot radio selected the 'Area Size' must be greyed out but when others radio button selected is must be active For Apartment radio selected or Villa radio selected, Plot Size must be greyed out. Hope that makes clear.... Its very Urgent kindly help me with this.. Thnks in Advnce Hi, Please i am confuse to know the work of this sign (!)...which is exclamation sign in programming. i have this code here which which i remove the exclamation sign (!)..it dont work but when i add it ,then it work. Here is the code <script type="text/javascript"> function getvalue() { var mytextfield=document.getElementById("mytext"); if(mytextfield.value!="") { alert("You Entered:"+mytextfield.value) } else{ alert("would you enter some text") } } </script> <input type="text" id="mytext" size="30"> <input type="button" value="check" onclick="getvalue()"> Please help me to understand the use of this sign !. Thank you. Clement Osei. 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. 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
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. hi again, I want to say thank you for all of the help and I have the last assignment that she wants us to do and I had to pull up another assignment that she wanted us to build upon( which is one of those coding without anything advance) Code: <html> <head> <title> COMSC 100 Assignment 10 by Dennis McNeill [1190802] </title> <script> function getInputAsText(_id){return document.getElementById(_id).value} function getInputAsNumber(_id){return parseFloat(document.getElementById(_id).value)} function setOutput(_id, _value){document.getElementById(_id).value = _value} function calculate() { // declare all variables var variable1 var variable2 var variable3 var variable4 var variable5 // get variable's value = getInputAsNumber() = getInputAsNumber() // perform concatenation // write output value setOutput("resultAsText",resultAsNumber) } </script> </head> <body> Directions:<br> Type 5 numbers and click go<br> The highest of the 5 will appear<br> It is okay to use a decimal point<br> Input values:<br> First<input id="variable1"><br> Second<input id="variable2"><br> Third <input id="variable3"><br> Fourth<input id="variable4"><br> Fifth<input id="variable5"><br> <input type="submit" value="go" onclick="calculate()"> Output<br> Result #1:<input id= "myResult1" size="25"> </body> </html> now she wants us to do max <beta and then name the variables with if a<b and I don't know if I put that in the concatenation or what to name my variables! ugh. NOT ASKING TO DO MY HOMEWORK 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 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 I'm new to programming in general and have had trouble deciding on a good starter project. I've decided to start with something that is (hopefully) pretty simple. I have about a dozen boxes full of vinyl records and would like to write a program to catalogue everything alphabetically by artist using prompts to ask for Album Title, Artist Title, and year. My question at this point is, is JavaScript a good way to do this? I have a fundamental knowledge of HTML, CSS, JavaScript and Ruby. I assumed JS would be the best way (that I know at this point) to do this project, but if I'm wrong, would love to hear it. What I don't understand at this point is how to output the information to a text file, or how to set up an interface to run the scripts. Any advice is very much appreciated. I'm currently using an automation software to automate a series of steps I perform on my computer. One of the tasks involves hundreds of If/Then loops, extracts text from websites using an embedded web browser, computes equations and write text files. The thing is, in order to share this with somebody else, they also need the same automation software installed, and then need to import it. So it's a process I'm trying to replace by creating a small program with a GUI that involves a simple installation on the user's PC (or ideally without installation). The language must be flexible enough to perform the same actions that I listed above - and more preferably. I'm a complete novice with anything besides HTML/CSS so I'm looking for A flexible programming language that isn't rocket science to learn from scratch and is ideal for small stand-alone programs The ability to create a GUI. I'd be happy to read any good reference you have about the language/design knowledge needed for GUI's. Thanks in advance 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. 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. =) |