JavaScript - 2 Javascript Questions
Hey everyone. I am very new at JavaScript and I need some help. I want to have a section on my home page where a person can choose a bike by clicking on a couple of arrows on the right and left ends of the bike. I want something similar to this type of program.
http://qlpros.com/ I don't want a border around the bike. I have been looking for a couple hours now and I haven't found anything. Any help would be much appreciated!! My other question is how to transfer javascript to an external style sheet in dreamweaver. Thanks!! Similar TutorialsI am newbie in javascript. While being studying it I have not understood some concepts well. JS is prototype-based language, as in Java it has one main prototype Object, also there are some other widely used object, like Array, RegEx, String ...... . So I can access and inherit from this objects/prototypes. So the questions is where do this object (declarations) are stored ? They are also allocated in memory ? Or when JS sees that there is declaration of some object is present i script it reads from file or whatever ? When I am using Function with key word new, what happens. As far as function is also object, it has field prototype and when calling this function with new it returns object of prototype type ? Am I right ? So if I haven't specified prototype it will returns object of Object type ? How does javascript knows about real type of variable. For example when I use regexp, it has method exec. I can call it on every variable. But I guest if variable doesn't have this field it returns undefined ? So the question is how does JS determine what real type of variable is ? Where this information is stored ? Closure in JS. I don't understand this concept well. I think of it like reference count in Java (used or been used by Garbage Collector). If we have a least one reference to variable it will still exist and it doesn't matter where it was declared. So making getter method inside another func makes it exists in memory. If I am wrong please give good explanation of this. Does JS runs in its own virtual machine like Java ? Or browser plays this role. I guess if it has GC, since one process cannot access address space of another process it should be something like virtual machine which controls memory allocation. I would be very grateful for help. Thx in advance. Reply With Quote 01-21-2015, 10:44 AM #2 Dormilich View Profile View Forum Posts Senior Coder Join Date Jan 2010 Location Behind the Wall Posts 3,532 Thanks 13 Thanked 372 Times in 368 Posts Questions About Javascript - JavaScript | Dream.In.Code Ok, so I have a couple of questions about JavaScript that I would like answered by the programming gurus on this forum, please. Firstly, I have an idea for an online text-based role-playing game (games like GangsterParadise, etc.), and I am wondering, is it possible (or advisable?) to create the site using nothing but HTML, CSS and JavaScript? Can it be done, and if so, are there any downsides to doing this? I have heard using strictly JavaScript as a programming language on its own, on a site where members will have their own password-protected accounts, should not be done, as there are serious security flaws - is this true, and if so, why? Secondly, most JS programmers on the forum have probably digested and been through hundreds and hundreds of books on the subject since beginning to learn JavaScript - in your opinion, what are the best books to get hold of, for a relative beginner to JavaScript? What book makes the language easy to understand, and doesn't have you scratching your head to make sense of what it is saying? Thanks a lot in advance for the help, it's much appreciated. Hello. I have a page that has bunch of moving elements, and obviously I want the movement to be smooth. It worked just great in chrome, but very chunky in firefox. I ran a profiler, found the bottleneck and dealt with it, so things work fine now, but after seeing the result of profiler I now have few questions: The function that is responsible for moving elements around takes 33% of time. Here's the code: Code: Tile.prototype.relocate=function(x,y){ this.elem.style.left=this.x=x; this.elem.style.top=this.y=y; } It's called from timer (setInterval) for elements that are not where they should be (they have .style.position set to "relative"). Is there a better way of moving elements around? Another function: Code: function type(code){ return code>>8; } It takes 13% of time. Now this is just ridiculous. 181854 binary shifts take 174.579ms. Is there a way to make it look like a function call but just replace the call with actual code at compile time, just like C's preprocessor? I'm quite new to JavaScript, but I wanted to add a feature to a sample website that I need to have done by tomorrow night. I have two HTML paragraphs which I will call "a" and "b". Below those paragraphs I have a text box and a submit button. This is how I declared them in the HTML doc: Code: <input type="text" name="message" value="Blank Message" id="newsmessage" /> Code: <input type="button" value="Post" id="submitbutton" onclick="updatepost()" /> Now when I click the submit button I want paragraph b to replace itself with paragraph a, and I want paragraph a to replace itself with the text in the text box. Here's the JavaScript that I have written. (I'm aware it's probably quite off.) Note: paragraph a is toppost, paragraph b is bottompost, the text box is named message, and I created p1 and p2 as temporary holders for the strings. Err... variables. Code: <script type="text/javascript"> function updatepost() { p2=document.getElementById("toppost"); document.getElementById("bottompost").innerHTML=p2; p1=document.message.elements[i]; document.getElementById("toppost").innerHTML=p1; } </script> As of right now the paragraph a holds the text "a" and paragraph b holds the text "b". When I click post paragraph a still reads "a" and paragraph b reads "[object HTMLParagraphElement]". Sorry for my minimal JavaScript knowledge; I have full intentions of fully learning the language quite soon. I just wanted to implement this feature in a site that I had to create and my deadline is tomorrow. Thanks guys! -Dave Hello! I have a few simple questions and I'm not having any luck with my Google searches. Any information is appreciated! Pardon my pseudo-coding... It's the simplest way to describe what I'm looking for. 1. I have a two dimentional array called List. I want to write a for loop to loop through the first dimension of the array. How is this done? Code: for (Line in List[][]) { write ( List[Line][1] + " = " + List[Line][2] + "<br/>"); } 2. Is there a simple example of how to create and use an object with multiple properties, functions, etc? For example, the following "person" object: Code: Person as object - property FirstName as string - property LastName as string - function Name = property FirstName + " - " + property LastName - property Children[] as array of Person objects - property Gender as string - property Mate as Person object - property DOB as date 3. Can enumeration be done easily in Javascript? Code: enum StatusFlags blank as 0 new as 1 free as 2 reserved as 4 sold as 8 endedum enum StatusDecoration new as "bold" old as "normal" free as "green" notfree as "red" reserved as strikethrough"" unreserved as "no-strikethrough" sold as "italics" unsold as "no-italics" endenum Thanks! more or less when a user has a command pop up in this prompt they are asked to type another item from a list with an okay or cancel at the bottom how do i stop the script if a user hits cancel and move onto the calculation step and by pass the other imput prompts? sorry if this isn't the clearest, i am new at javascript. THanks in advance. I have a few buttons on a page I'm developing and I want the onclick event to call a javascript function in an external file and execute it. I would like to be able to pass a parameter to that function and then either have the function take the user to a new URL or make changes to the webpage content. Initially (just to test) I had inline javascript that caused an alert to popup. That worked fine. Next I took the inline code and put it in a function in an external javascript file that was referenced in the HTML: Code: <script type="text/javascript" src="../assets/js/ews-js.js"></script> <a link="www.xx.com" class="sk-shop-button" onClick="onclick_shop_button">Shop for Supplies</a> The function is as follows: Code: function onclick_shop_button() { window.alert('Life Is Good!'); return false; } When I attempt to call it this way nothing happens. I'm guessing I should not be using a link there since I have to build the URL inside the Javascript (for now though the Javascript is just showing an alert). In one use case I want to be able to pass a parameter which would contain a product name so the function could load the correct webpage. So the function would have to build the URL using the product name as part of the URL then load that page. In a different use case (for a different button) the user would click on an EDIT button that would then update parts of the webpage allowing the user to click on areas to delete content. I am not sure how to implement either use case. I know I can use CSS to modify the look of the webpage and then use subsequent onclick events to do the deleting but am not sure how to delete HTML from within Javascript. Same with how to go to a new URL from within Javascript. Finally I am not sure why the inline Javascript works but the external does not. Any help would be GREATLY appreciated! I need help with the javascript in this page. I don't know how to do what it is asking me for and I am running out of time. Thanks a million, RHonda <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script> function numberGuess() { stringVar=prompt("Enter your guess number"); while (stringVar<999) { } } </script> <script> function enterNames() { stringVar=prompt("Enter name"); } </script> <script> function enterProducts() { stringVar=prompt("Enter product name"); return } </script> </head> <body> <p> </p> <h1>WDV221 Intro Javascript</h1> <h3 align="center">Javascript Loops</h3> <p>Topics: loops, for loops, while loops, sentinels!</p> <p>Place all script code on this page.</p> <p>1. Create a function that will ask you for a number until you enter 999 which will end the loop. You do not need to display the number. </p> <p>2. Create a function that will ask you for a name until you tell the function that you do not have any more names. After you enter each name it will ask you if you have more names to enter. If you enter yes the process will continue. Display each name at the end of the following sentence.</p> <p>The name you entered is: </p> <p>3. Create a runtime script that will use a prompt( ) to accept how many products will be displayed. Use a for loop to display "Product Name" and the product number as a <p> element.</p> <p><strong>Example output:</strong></p> <p>Product Name 1</p> <p>Product Name 2</p> <p>...</p> <p>4. Create a runtime script that will use a nested for loop to create a table with 3 rows and 5 cells. Place the same number or a letter in each cell. </p> <p>Hint: Write a table in HTML. Do a row first then do multiple rows. </p> <p>5. Create a function called totalSales( ) that will ask the user to enter an amount until you enter "done". Add those amounts together and display them in an alert when the user is done entering amounts..</p> <p>Have fun!!</p> </body> </html> I have been stuck on a few questions in my computer science class about javascript. I have read the entire chapter but I cannot find the answers to these questions. I believe that I have tryed every important word in every section of the chapter in all questions. I have used every source for this information available to me and after all of them found this website. This is probably extremely basic information but I am unable to solve it. The questions include(They were not numbered in assignment however I have numbered them to try and help): 1. The Graphics class method for displaying text is _________. 2 The applet or JFrame method that returns the Container object that represents the applet's (or JFrame's) space (its visual "real estate") is __________. 3. The import statement needed to use button components in applets or GUI applications is ________. 4. The general term for methods that are invoked as a result of a user action is __________. 5. Clicking a button results in the creation of an _____________ object to represent the button click. 6. Clicking a button may result in notification being sent to an ________ object. 7. The method used to arrange for a button to notify another object when it is clicked later is to an __________. 8. The class definition for objects that receive notifications of user operations on controls like buttons must contain the following phrase: __________. These questions are the last ones that I have left. I have tryed everything. I can submit answers as many times as I want, however there is a deadline. Hi, im sorta a newbie but have a few questions i cannot find online anywhere. By the way im trying to create a chrome extension . Its a fairly simple extension, all i want it to do is select a few buttons automatically when the page is loaded. Without me having to click anything. A bot persay. How to automatically select a button/drop down menu How to save a form How to submit a form to a website How it works if you dont get it? Selecting a certain size like S/M/L, color, or anything of that nature AUTOMATICALLY WITHOUT HAVING TO CLICK ANYTHING. Which then adds to my cart. Thats all i want it to really do. Thanks for reading. I recently read a couple blogs that listed some points for writing better Javascript code. Several points applied to the code I write, so they caught my eye. For example, Quote: Use === instead of == and Quote: Use [] Instead of New Array() All of my programs are for numerical computations. Input comes from a textarea box, it is converted to floats, then it is put in arrays, compared, manipulated, etc. For example, Code: rawArray = rawtextareaString.split(/\s+/g); . . . tempx = parseFloat(rawArray[k]); . . . sqAMatrix[i][j] = tempx; . . . Before I rush out and revise all my code to incorporate these suggestions, are there are concerns I should be aware of? Gotchas? Compatibility issues? Should I even bother? Hello everyone. I just came across a customer that wants me to place 1 video and 1 swf image player in the same place on there website. I tried this with a div layer where i put the video over the swf image but with a different monitor it would move. I did have a time out process of 2.1 mins. Does anyone know of any code that i could put in that would show the video for the time and when it finished it would show the swf images? If so can you tell me how to do this or help me with the code? If you need to see the current code it is simple just straight html done by a different coder. I would of done it with a css but he didn't want to. If you know of a way let me know. Allow the search function to start anywhere within the name, rather than just at the start (so searching for "icha" would match "Richard". If more than 3 matches are found during the search don't display them just inform the user of the number of matches and suggest they search more precisely. Every time the user enters a "bad command", informs them of how many more they are allowed before they are locked out of the system. Introduce and implement an option to change a user's phone number. Reply With Quote 01-14-2015, 08:34 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts Look he http://www.codingforums.com/rules.htm And read rule 1.5 We do *NOT* do your homework for you. I will bet that the answer you got for "search array string" is too advanced. That is, your instructor will know immediately that it is not your own work. You need to *TRY* to do your homework yourself. If you get stuck on one particular point, where your code almost works but not quite, *THEN* is the time to ask a question. But you need to show your work so far. And, if you can, explain what is not working. ********* On a side note: How the heck is anyone here supposed to be able to help you with this part of the homework: Every time the user enters a "bad command", informs them ... You haven't even told us what a "command" is! If you *are* going to ask for help, you have to give enough information that someone can understand the question. But, again, don't expect help until you can (for example) at least show that your code is TRYING to process a "command". Same applies to Introduce and implement an option to change a user's phone number. You haven't bothered to show the data structure that even *HAS* phone numbers in it! Talk about incomplete information! I hired psd2html.com to code my portfolio website because I had no idea where to start. They designed a specific gallery for me and I don't like it anymore, and it's the last thing holding my back from making my portfolio live. Here is what it looks like right now: http://www.mustlovepink.com/index2.html I attached an image that describes what I would like the gallery to look like. I don't think it's all that different, but the code is honestly such a mess that I need someone to help me with it. I don't even know where to begin If you need more information in order to tell me, feel free to let me know. I really want to get this thing figured out. If you have input on the questions already in the FAQ or want to suggest a new question for someone to write an answer to, please post here. Index: How do I debug JavaScript as used on a webpage? How do you read, write, delete and detect support for cookies? What are the limits on cookies? What is Javascript good for? How do I format a number so that it always has two decimals? How do I trim whitespace from the beginning and end of a string? Why does parseInt('08') generate 0? How do I read/write files? How do I get multiple scripts to work on a single page? How do I convert a decimal number to hexadecimal, and the other way around? How do I add ordinals (st, nd, rd, th) to a number? How do I use JavaScript in external files? How can I use Javascript to protect my web pages? How do I shorten my lengthly if() statements? How do I hide my JavaScript source code? How do I use 'javascript:' links? Browsers: moz: Mozilla. This in general covers both Mozilla and Mozilla Firefox, and often also includes other Mozilla based browsers such as K-Melon, Galeon, Camino. <http://mozilla.org/products/>, Any platform. ien: Microsoft Internet Explorer in general. n stands for version number. ienw: Microsoft Internet Explorer for Windows. <http://www.microsoft.com/windows/ie/default.asp>, Windows ienm: Microsoft Internet Explorer for Mac. <http://www.microsoft.com/mac/product...ternetexplorer>, Mac safn: Apple Safari (based on KHTML and KJS by KDE) <http://www.apple.com/safari/>, Mac OS X konq: KDE Konqueror. <http://www.konqueror.org/>, X11 opn: Opera. Normally we're talking about newest verion on Windows and Linux and Mac. <http://www.opera.com/download/>, Windows, Linux, Mac. nsn: Netscape6, Netscape7, Netscape8. Netscape browser based on Mozilla. nnn: Netscape Navigator. Netscape browsers up to version 4.x. ncn: Netscape Communicator. Same as nn4.x. Hi, I've just starting my way with javascript and I have 2 questions: 1 - what is the different between *.html file and *.js file ? 2 - How can I run javascript file from cmd command line ? ( I have Win' XP ) Thanks in Advanced my code: <html> <head> <title>Learning Javascript</title> </head> <body> <p>Hello World! </body> </html> Inside of here if you save as a .html and open it it will pull up the game a series of 5 boxes and 5 answers underneath, Currently those 5 answers correctly correlate with each box so you know what they are considering you don't have the .jpgs to display them. The one in bold is the "question" when you click on the one that correlates with the bold it should tell you Correct! 100. 100 being your score and if you get it wrong it will say sorry! and then take your score down to a 50 since you got 1 out of 2 wrong. The problem is when you get it wrong it also immediatly says Congrats! after you get it wrong So it will prompt a Sorry! alert and a Congrats! alert on the wrong answer. The second problem is after the user gets it right or wrong, I need it to re random the list of answers and images. Whilst keeping the score intact for up to 20 questions. Please help! Code: <body> <script type="text/javascript"> var counter = 0; var correct = 0; function show_alert0() { {counter++;} if (randomname0 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert1() { {counter++;} if (randomname1 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert2() { {counter++;} if (randomname2 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert3() { {counter++;} if (randomname3 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } function show_alert4() { {counter++;} if (randomname4 != final) {alert("Sorry." + (( correct / counter ) * 100 ));} else {correct++;} {alert("Congrats!" + (( correct / counter ) * 100 ));} } </script> <script type="text/javascript"> var randomnumber0=Math.floor(Math.random()*66) var randomnumber1=Math.floor(Math.random()*66) var randomnumber2=Math.floor(Math.random()*66) var randomnumber3=Math.floor(Math.random()*66) var randomnumber4=Math.floor(Math.random()*66) while (randomnumber0==randomnumber1 || randomnumber0==randomnumber2 || randomnumber0==randomnumber3 || randomnumber0==randomnumber4) {randomnumber0=Math.floor(Math.random()*66)} while (randomnumber1==randomnumber0 || randomnumber1==randomnumber2 || randomnumber1==randomnumber3 || randomnumber1==randomnumber4) {randomnumber1=Math.floor(Math.random()*66)} while (randomnumber2==randomnumber0 || randomnumber2==randomnumber1 || randomnumber2==randomnumber3 || randomnumber2==randomnumber4) {randomnumber2=Math.floor(Math.random()*66)} while (randomnumber3==randomnumber0 || randomnumber3==randomnumber1 || randomnumber3==randomnumber2 || randomnumber3==randomnumber4) {randomnumber3=Math.floor(Math.random()*66)} while (randomnumber4==randomnumber0 || randomnumber4==randomnumber1 || randomnumber4==randomnumber2 || randomnumber4==randomnumber3) {randomnumber4=Math.floor(Math.random()*66)} document.write('<p style="text-align:center">') document.write('<em>Click on the ribbon that matches the name below.</em><br/><br/>') document.write('<button type="button" height="300" width="300" onclick="show_alert0()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber0+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert1()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber1+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert2()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber2+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert3()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber3+'.jpg" height="300px" width="200px"></button>') document.write('<button type="button" height="300" width="300" onclick="show_alert4()"><img src="https://www.intelink.gov/sites/afpaa/Shared%20Documents/rank'+randomnumber4+'.jpg" height="300px" width="200px"></button><br/>') document.write('</style>') var name = new Array(); name[0] = "Airman"; name[1] = "Airman 1st Class"; name[2] = "Senior Airman"; name[3] = "Staff Sergeant"; name[4] = "Technical Sergeant "; name[5] = "Master Sergeant"; name[6] = "First Master Sergeant"; name[7] = "Senior Master Sergeant"; name[8] = "First Senior Master Sergeant"; name[9] = "Chief Master Sergeant"; name[10] = "First Chief Master Sergeant"; name[11] = "Command Chief Master Sergeant"; name[12] = "Chief Master Sergeant of the Air Force"; name[13] = "2nd Lieutenant"; name[14] = "1st Lieutenant"; name[15] = "Captain"; name[16] = "Major"; name[17] = "Lieutenant Colonel"; name[18] = "Colonel"; name[19] = "Brigadier General"; name[20] = "Major General"; name[21] = "Lieutenant General"; name[22] = "General"; name[23] = "General of the ..."; name[24] = "Private"; name[25] = "Private 1st Class"; name[26] = "Specialist"; name[27] = "Corporal"; name[28] = "Sergeant"; name[29] = "Staff Sergeant"; name[30] = "Sergeant First Class"; name[31] = "Master Sergeant"; name[32] = "First Sergeant"; name[33] = "Sergeant Major"; name[34] = "Command Sergeant Major"; name[35] = "Sergeant Major of the Army"; name[36] = "Warrant Officer (W01)"; name[37] = "Chief Warrant Officer (CW2) "; name[38] = "Chief Warrant Officer (CW3)"; name[39] = "Chief Warrant Officer (CW4)"; name[40] = "Chief Warrant Officer (CW5)"; name[41] = "Private First Class"; name[42] = "Lance Corporal"; name[43] = "Corporal"; name[44] = "Sergeant"; name[45] = "Staff Sergeant"; name[46] = "First Sergeant"; name[47] = "Sergeant Major"; name[48] = "Master Gunnery Sergeant"; name[49] = "Warrant Officer (W0)"; name[50] = "Chief Warrant Officer (CW02)"; name[51] = "Chief Warrant Officer (CW03)"; name[52] = "Chief Warrant Officer (CW04)"; name[53] = "Chief Warrant Officer (CW05)"; name[54] = "Seaman Apprentice"; name[55] = "Seaman"; name[56] = "Petty Officer Third Class"; name[57] = "Petty Officer Second Class"; name[58] = "Petty Officer First Class"; name[59] = "Chief Petty Officer"; name[60] = "Second Chief Petty Officer"; name[61] = "Master Chief Petty Officer"; name[62] = "Fleet / Command Master Chief Petty Officer"; name[63] = "Master Chief Petty Officer of the Navy"; name[64] = "Chief Warrant Officer (CW02)"; name[65] = "Chief Warrant Officer (CW03)"; name[66] = "Chief Warrant Officer (CW04)"; var randomname0 = name[randomnumber0]; var randomname1 = name[randomnumber1]; var randomname2 = name[randomnumber2]; var randomname3 = name[randomnumber3]; var randomname4 = name[randomnumber4]; document.write(randomname0+'<br/>'+randomname1+'<br/>'+randomname2+'<br/>'+randomname3+'<br/>'+randomname4+'<br/>') var randomname = new Array(5); randomname[0] = name[randomnumber0]; randomname[1] = name[randomnumber1]; randomname[2] = name[randomnumber2]; randomname[3] = name[randomnumber3]; randomname[4] = name[randomnumber4]; var randomnamenum=Math.floor(Math.random()*4); var final=randomname[randomnamenum]; document.write('<br/><br/><pstyle="text-align:center"><strong>'+final+'</strong></style><br>') </script> </body> My code goes through the answer function (below) and it determines if you answered green. If you answered green a popup says correct other wise incorrect. How can I modify my code so that I can add multiple answers for different questions.Example q1.html what color is the grass? q2.htm what color is the sky? . . q20.html what day of the week was the last baseball game? _____________________________________________________ now in my javascript every question is going to go through the answer function and think the answer is green. that would be correct for q1.html but what if i am on q20.html and it goes through the answer function. It will think the answer is green. So how can i change the code so q1.html knows that the answer is green. q2.html knows the answer is blue? here is my code Code: var n = 16; // modify this for number of seconds to answer document.getElementById( 'time').value = "Answer in " + n + " seconds"; var i = setInterval('count()' , 1000); var tooLate; function count() { tooLate = 0; n--; if(n >=0) { document.getElementById( 'time').value = "Answer in " + n + " seconds"; } else { clearInterval(i); alert("Too late!"); document.getElementById('answer').value = ""; tooLate = 1; } } function answer() { var correct = "green"; // This is the correct answer if (tooLate == 0) { if(document.getElementById( 'answer').value == correct) { clearInterval(i); alert("Right Answer with " + n + " seconds remaining"); } else{ clearInterval(i); alert("Incorrect! The answer was " + correct); } } submitform(); //submit form function submitform() { document.forms["myform"].submit(); } } Thank you! Hi again, I have 2 new questions for you all! 1.) *RESOLVED* 2.) So in this form: Code: <form name="form" action="email.php" method="post"> <div id="dynamicInput"> <br> <input type="checkbox" name="1" /><input type="text" name="i[]"> </div> <input type="button" value="Add another text input" onClick="addInput('dynamicInput');"> <br> <input name="email" type="text"> <br /> A12098 <input name="verify" type="text"> <input name="submit" type="submit"> </form> I have a button that will add a form element to the form. In this case, it adds a checkbox and a text box. The name on the checkbox goes up from 1-30 (thats the max amount of fields that can be added) and the text box has a name of i[]. Is it possible for the user to click on the checkbox and the corresponding text box (the one next to the checkbox) will be disabled so editing is stopped? Then they could un-click it and it would be editable again. Thanks in advance! |