JavaScript - Javascript Make Website Slow ?
I heard that when we put javascript in website, then site takes time to open, is it correct ? If yes then which script is good for website.
Similar TutorialsHello, I would like to know how to make a website (in this case, a parent div) viewable only if JavaScript is enabled? I tried to develop a code that can do this, but could not find the solution. Code: <html> <head> <script type="text/javascript"> window.onload=function() var="true" if(JavaScript.enabled) { document.getElementById('true') } OnClick() {document.getElementById('toggle').onclick=function() {document.getElementById('jahava').style.display=(document.getElementById('jahava').style.display!='none')?'none':'';}} </script> </head> <body> <noscript>You must have JavaScript enabled to view the website.</noscript> <div id="jahava">Contents Here</div> </body> </html> Heya guys. My gallery javascript is running very laggy in IE8. Here's an example: www.amex-trading.dk/pizzaovne.php It works fine in chrome, but it's slow when using IE. Any suggestions? Hello guys, The title says it all, my javascript hover menu is running perfect in chrome, but really slow in IE. Take a look here - the menu is called "Produkter" Thanks in regard hi guys I am looking at this template: http://www.csstemplatesfree.org/prev...ero/index.html I think the sliding at the top happens way too frequently. How can I slow it down? I think it would be better if the slides change once every 6 seconds. The left-hand (main) menu for my website (www.displaycentre.co.uk) is extremely slow on IE8 on some PCs yet fine on others. No problems with other browsers at all. I know that the menu is huge but cannot understand why the speed is fine on some (even low spec) PCs and yet it is painfully slow on others. It is slow on all of my work PCs (some with 512Mb RAM others have 2GB!) and also my PC at home (which is brand new this weekend, 2Gb RAM and only Windows XP + all updates loaded so far). Any body out there got any ideas? My developer is simply putting it down to the way in which IE8 copes with such huge menus? Thanks in anticipation. Chris Can you tell me a similar way to do this? Greetings! I am currently working on my own company's website I am currently working with the FAQ page and I need to make a simple textbox, where visitors can type and ask a question and submit it, the question the visitor typed needs to be read by javascript from a seperate xml file which should be read with javascript. Now i dont know how to start with this and I would appreciate if someone could give me a lead on what things i should do and etc. Best regards Obs hi everyone! i downloaded a Facebook Page template recently. the template works great, but i wanted to add one thing. here is the demo of the code: http://www.facebooktemplates2u.com/d...best_business/ here is where you can download the template: http://www.schoolofrok.com/facebook/html.zip/ anyhow, the part i want to change is the link that directs it to the content. for example, when you scroll over About Us, the little pop up from the bottom comes out. when you click it, it takes you to the About Us content. what i wanted to do, is make it so that when you click the whole jpg, it can take you to the content also. i noticed that the small link that pops up is too tiny and people get confused on where to click. any suggestions? TIA! Hi! I'm as new as they come when it deals with website development but forums have been useful to me in the past and I'm hoping I can get some kind of direction from all the wonderful people on this forum! I have an idea for a website that I'd like to pursue, and it would need functions such as: -Live news feed -Member logins, profiles, ability to rate/leave feedback for members -Mobile phone friendly -Comment on postings -Create an intro video (maybe even with animated stick figures to explain how the site works) -Accept paypal or other payment method -And basically, need to understand the monthly maintenance cost of all these functions, how to minimize expenses, etc. I know it seems far fetched for a newbie! But I need to know if this is possible.. how would I begin implementing a site like this.. Do I need to find a programmer to code it from scratch? Are there pre-written scripts available for all the functions I listed? What can I expect the costs to be? What's the best way to move forward? Ok, so if you navigate ovr to my website "http://www.mancunianmacca.co.cc" you will notice that a box pops up asking for your name. When you type it in it adds it to the page. Is there a way I can get this to remember the users input and only ask them once then remember. Like cookie or anything. If you need any extra things. Just ask.
Ok so im new to javascript and I have a button in an interface for an app. It's like drag and drop and i want this button to link you to a certain website searching for what the user types in the searchField1 box. The button is button16. Such as you type dogs into the text box and you click the google button among other search engines and it will redirect you to a google search doing a search for dogs. But how do I make this button search google and search for whats in searchField1. I would really appreciate the help. Im looking everywhere to learn this but just cant find it. If you could tell me how or send me a link to a tutorial that would be great. Thanks! Here is the code: I don't know where and what to add to do that. Please help. 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 I have a script that clicks links how can i make it not click a certain. Such as how to make it dont click red link or dont click bold links. Code: var waiting_time = 30; var range_to = 15; var shuffle = function(o){ if(Math.floor(Math.random() * o.length) % 2) return o; for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); return o; }, isAds = function(o) { try { return o.href.match(/cks\.php\?k\=[0-9A-Fa-f]+\&cdk\=flase/) != null && o.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('div')[1].className == 'image' } catch(e) { return false } }, correctURL = function(r) { return window.location.href.match(r) != null }, setStatus = function(o, m) { o.parentNode.parentNode.parentNode.innerHTML = m }, addevent = function(o, f) { document.getElementById(o).addEventListener('click', f, false) }, byTag = function(t) { return document.getElementsByTagName(t) }, byName = function(n) { return document.getElementsByName(n) }, newTag = function(t) { return document.createElement(t) }, getwtime = function(o) { var i, a = o.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('div'); for(i = 0; i < a.length; i++) if(a[i].className == "counter") return a[i].innerHTML.match(/([0-9]+) seconds/)[1] }, strip = function(s) { var str = String(s).split("</td>").join("\r"), reg = /<td\s*width=['"]?100\%['"]?\s*>([^\r]+)\r/, match = str.match(reg), search = str.search(reg), out = [], i = 0, tmp; while(match) { str = str.substr(search + match[0].length, str.length); out[i] = match[1].replace(/\s*<script[^>]+>[\S\s]+<\/script>\s*/, ""); out[i] = out[i].replace(/<img[^>]+>/, ""); i++; match = str.match(reg); search = str.search(reg); }; return (out.length ? "<table><tr><td>"+out.join("</td><td>")+"</td></tr></table>" : "NO MATCH"); }, login = function() { var a = byTag("a"), I; for(I = 0; I < a.length; I++) if(a[I].href.match(/logout\.php/)) return true; return false }(), autosurf = false; if(correctURL(/\/ads\.php/)) { if(login) { var A = byTag("a"), i, html = "", timer, table = document.getElementById('content'), robot = newTag('div'), urls = [], current = 0, msg, tmr, load = function() { clearInterval(timer); timer = null; if(!urls[current]) { if(typeof autosurf == 'function') autosurf(); return }; var ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { try { if(ajax.readyState == 4) { if(ajax.status == 200) { if(String(ajax.responseText).match(/You have already viewed this advertisement/)) { msg.innerHTML = "Ads already opened, loading next ads..."; setStatus(urls[current], "OPENED"); current++; timer = setInterval(load, 1000) } else if(String(ajax.responseText).match(/Couldn't find an advertisement/)) { msg.innerHTML = "Ads expired, loading next ads..."; setStatus(urls[current], "EXPIRED"); current++; timer = setInterval(load, 1000) } else if(String(ajax.responseText).match(/You don't have permission to view this advertisement/)) { msg.innerHTML = "Forbidden Ads, loading next ads..."; setStatus(urls[current], "FORBIDDEN"); current++; timer = setInterval(load, 1000) } else { var j = urls[current].wtime, validate = function() { var ajx = new XMLHttpRequest(); ajx.onreadystatechange = function() { try { if(ajx.readyState == 4) { if(ajx.status == 200) { msg.innerHTML = "Ad click, opening next ads..."; setStatus(urls[current], "Ad Clicked & Confirmed"); current++; timer = setInterval(load, 1000) } else { msg.innerHTML = "Connection error, retrying..."; validate() } } } catch(e) { msg.innerHTML = "Validation error, retrying..."; validate() } }; msg.innerHTML = "Validating..."; ajx.open("GET", "cmp.php?complete&", true); ajx.send(null) }; tmr = setInterval(function() { if(j < 0) { validate(); clearInterval(tmr); tmr = null; return }; msg.innerHTML = "Ads loaded, waiting for "+j+" seconds..."; j-- }, 1000) } } else { msg.innerHTML = "Loading error, retrying..."; timer = setInterval(load, 1000) } } } catch(e) { msg.innerHTML = "Loading error, retrying..."; timer = setInterval(load, 1000) } }; msg.innerHTML = "Loading ads <b id='JFClickBot-current'>\""+(urls[current].parentNode.parentNode.parentNode.getElementsByTagName('a')[0].innerHTML)+"\"</b>...<br /><div id='JFClickBot-loading'></div>"; ajax.open("GET", urls[current].href, true); ajax.send(null) }; for(i = 0; i < A.length; i++) { try { if(isAds(A[i])) { urls[urls.length] = A[i]; urls[urls.length - 1].wtime = getwtime(A[i]) } } catch(e) {} }; robot.id = "JFClickBot-container"; robot.align = "center"; html = "<style>"; html += "#JFClickBot-container *{font-family:arial;color:black;font-weight:bold;text-decoration:none}"; html += "#JFClickBot-container{display:block}"; html += "#JFClickBot,#JFClickBot-title,#JFClickBot-container a.button{-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;border: 1px solid #d91a2d}"; html += "#JFClickBot-container a.button{padding:10px;color:#000;background:#d91a2d}"; html += "#JFClickBot-container a.button:hover{color:#fff;background:#333}"; html += "#JFClickBot{padding:2px;display:block;width:900px;background:#fff;text-align:left}"; html += "#JFClickBot-title{display:block;padding:5px;background:#d91a2d;color:#fff}"; html += "#JFClickBot-msg{line-height:2em}"; html += "</style>"; html += "<div id='JFClickBot'><div id='JFClickBot-title'>JFClickBot For Gen4 Sites</div><br /><div id='JFClickBot-msg' align=center>"; html += "<b style='font-size:20px'>Warning</b><br />By Using This Tool You Agree to The Terms Of Use On <a href='http://clickbots.justfreebies.net' rel="nofollow" target='_blank'>ClickBots</a>.<br> We Are Not Resposible For Your Action, USE AT YOUR OWN RISK.<br><a href='http://clickbots.justfreebies.net' rel="nofollow" target='_blank'>© PTC ClickBots</a>"; html += "</div><br />"; html += "<center>"+(urls.length ? "<a href='javascript:;' class='button' id='adsclick'>Click All Ads ("+urls.length+")</a>" : "<a href='javascript:;' class='button'>No ads</a>")+" <a href='http://clickbots.justfreebies.net/features.php' class='button' rel="nofollow" target='_blank'>Features</a> <a href='http://clickbots.justfreebies.net/purchase.php' class='button' rel="nofollow" target='_blank'>Purcahse Site</a> <a href='http://clickbots.justfreebies.net/donate.php' class='button' rel="nofollow" target='_blank'>Donate</a></center><br />"; html += "</div></div>"; robot.innerHTML = html; table.parentNode.insertBefore(robot, table); msg = document.getElementById("JFClickBot-msg"); if(urls.length) { urls = shuffle(urls); addevent("adsclick", function(){ autosurf = function() { msg.innerHTML = "Done !"; alert(msg.innerHTML); }; this.parentNode.style.display = 'none'; timer = setInterval(load, 1000); }) }; addevent('silversurfer', function(){ alert("Sorry this features isnt available yet."); return; this.parentNode.style.display = 'none'; msg.innerHTML = "Auto surf mode activated..."; var adscontainer = newTag('div'); document.body.appendChild(adscontainer); adscontainer.style.display = 'none'; autosurf = function() { urls = []; current = 0; msg.innerHTML = "Reloading ads, finding new ads..."; var sec = Math.ceil(Math.random() * range_to * 60), j = sec, tm, ajx, reloadads = function() { msg.innerHTML = "Reloading ads, finding new ads..."; ajx = new XMLHttpRequest(); ajx.onreadystatechange = function() { try { if(ajx.readyState == 4) { if(ajx.status == 200) { msg.innerHTML = "Loaded, clearing codes and finding available ads..."; adscontainer.innerHTML = strip(ajx.responseText); A = adscontainer.getElementsByTagName('a'); for(i = 0; i < A.length; i++) { try { if(isAds(A[i])) urls[urls.length] = A[i] } catch(e) {} }; if(urls.length) { urls = shuffle(urls); msg.innerHTML = urls.length + " ads found"; timer = setInterval(load, 1000) } else { msg.innerHTML = "No ads found"; autosurf() } } else { msg.innerHTML = "Loading error, retrying..."; reloadads() } } } catch(e){ msg.innerHTML = "Loading error, retrying..."; reloadads() } }; ajx.open('GET', 'ads.php', true); ajx.send(null) }; tm = setInterval(function() { if(j < 0) { clearInterval(tm); tm = null; msg.innerHTML = "Time's up, reloading..."; reloadads() } else { msg.innerHTML = "Waiting for "+j+" seconds before reloading..."; j-- } }, 1000) }; if(urls.length) timer = setInterval(load, 1000) else autosurf() }) } } else if(correctURL(/\/register\.php/)) { var r = byName('6')[0], ref, cty, ori; if(r && force_referal_to) { ref = newTag('input'); ref.type = "hidden"; ref.name = "6"; ref.value = force_referal_to; r.form.insertBefore(ref, r.form.firstChild); r.name = "ref"; r.value = ""; cty = byName('7')[0]; ori = cty.value; cty.parentNode.removeChild(cty); r.form.getElementsByTagName('table')[0].rows[7].cells[1].innerHTML = "<input type=text name='7' value='"+ori+"' style='text-transform:uppercase' />" } } else if(correctURL(/\/forum/)) { try { var name = byName('a_name')[0], tr = newTag('tr'); name.parentNode.parentNode.parentNode.insertBefore(tr, name.parentNode.parentNode); tr.innerHTML = "<td>Username</td><td>:</td><td><input type=text name='a_name' value='"+name.value+"' style='width:100%'/></td>"; name.parentNode.removeChild(name) } catch(e) {} } Hi guys, I want to add a big pic to my website for background, and the pic can change size with the displayer size. Can JavaScript do it? This is my website code. How can i make it? Thanks you! Code: <!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" dir="ltr" lang="en"> <head> <title>Buy Cheap Jordans|Air Jordans Retro|Air force ones|Nike Dunks|gucci bags,bags wholesale</title> <link rel="icon" href="favicon.ico" mce_href="favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="favicon.ico" mce_href="favicon.ico" type="image/x-icon"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="nike air jordan shoes, zoom kobe shoes, nike dunk sb shoes, brand handbag" /> <meta name="description" content="Buy Cheap wholsale nike air jordan shoes, nike kobe shoes, dunk sb shoes, lv handbag, gucci shirts,online shop" /> <meta http-equiv="imagetoolbar" content="no" /> <base href="http://example.com/" /> <link rel="stylesheet" type="text/css" href="http://example.com/includes/templates/nike/css/stylesheet.css" /> <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="http://example.com/includes/templates/nike/css/stylesheet_ie6.css" /><![endif]--> <script type="text/javascript" src="includes/templates/template_default/jscript/jscript_imagehover.js"></script> <script type="text/javascript" src="includes/templates/template_default/jscript/jscript_index.js"></script> </head> <body id="indexHomeBody"> <div id="mainWrapper"> <script type="text/javascript"> function help_display_block(id){ if(document.getElementById(id).style.display=='block'){ document.getElementById(id).style.display='none'; }else{ document.getElementById(id).style.display='block'; } } function help_display_none(id){ document.getElementById(id).style.display='none'; } </script> <div style="position:relative;"> <div onclick="help_display_block('help_d')" style="position: absolute; width:236px; height:35px;left:744px;top:70px;+top:66px;_top:68px "><img src="images/livetop.gif"/></div> <div id="help_d" style="position: absolute; width:236px; height:174px;left:744px;top:103px; +top:102px;background:url(images/livechatbg.gif) no-repeat left top; padding:10px; display:none;"><br /> <div style=" padding-left:10px;" > <A href="msnim:chat?contact=cheapshoesbag@aol.com" target=blank><img src="images/chat.gif" width="194" height="61" /></A><br /> <br /> <div style="padding-bottom:5px; font-weight:bolder"> E_mail:</div> <a href="mailto:cheapshoesbag@aol.com">cheapshoesbag@aol.com</a> <div style="padding-bottom:5px; font-weight:bolder"> MSN:</div> cheapshoesbag@hotmail.com</div> <div class="live_close" style="float:right; padding-right:20px" onclick="help_display_none('help_d')" ><img src="images/close.gif"/></div> </div> </div> <div id='key_wholesale'> Welcome! <a href="http://example.com/index.php?main_page=login">Log In</a> or <a href="http://example.com/index.php?main_page=create_account">Register</a> <!-- AddThis Button BEGIN --> <script type="text/JavaScript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script> </div> <!--bof-header logo and navigation display--> <div class="wrap"> <a href="http://example.com/" id="hohologo" title="Welcome to our site!"> </a> <div> <h1 id="top_ueserinfo">nike air jordan shoes, zoom kobe shoes!</h1> <div id="toptab"> <ul> <li><a href="http://example.com/index.php?main_page=account" id="myAccount" class="hide" rel=nofollow><span>My Account</span></a> <!--[if lte IE 6]> <a href="#" id="myAccount"><span>My Account</span> <table><tr><td> <![endif]--> i need a racing game in java graphics doesn't matter but speed should be good ?
Hello, Actually i know nothing about javascript. i have form and i need help to make javascript this is the form: </head> <SCRIPT language = "javascript"> function checkTotal() { function calculate() { A = parseFloat(document.form1.Qty.value); B = document.form1.selection.value; ---> 'please help i don't know the script command about onClick' and onChange combination' C = (A + B) * document.form1.total.value = C; } </SCRIPT> <body> <form name="form1" method="post" action=""> <table width="66%" border="0" id="form_table"> <caption> My Form </caption> <tr> <th width="41%"> <p>Qty ›</p></th> <td width="59%"><p> <input type="text" size="7" name="Qty"> <select name="selection" id="selection" onChange='Value'> <option value"1.00">Doll 1</option> <option value"2.00">Doll 2</option> <option value"3.00">Doll 3</option> <option value"4.00">Doll 4</option> </select> <br> Enter Qty and selection</p></td> </tr> <tr> <th>Merchandise ›</th> <td> <p> <input type="radio" name="None" value="0.00" onClick=""> None<br> <input type="radio" name="Key Chain 1" value="2.00" onClick=""checked> Key Chain 1<br> <input type="radio" name="Key Chain 2" value="3.00" onClick="" /> Key Chain 2</p></td> </tr> <tr> <th>Additional ›</th> <td><input type="checkbox" name="Story Book" value="4.00" onClick="" checked="checked" /> Story Book <br> <input type="checkbox" name="Mug" value="3.00" onClick="" /> Mug <br></td> </tr> <tr> <th>TOTAL›</th> <td><input type="text" style="background-color: #DCDDDD;" size="17" value="" name="Total" /></td> </tr> <tr> <th> </th> <td> <input type="submit" name="submit" value="Calculate" onClick = "javascript:calculate()"> <input type="reset" value="Reset"> </td> </tr> </table> </form> </body> </html> i need to get result from TOTAL checkout(input text) that sum from the value of options above (dropdown menu, checkbox, and radio button) multiplied by tax (4%) Coding master please help. Thank you very much. Hi! frnds, I was wondering if you could help me with the JavaScript programing... Every possible help will be appreciated I am very new to the world of programming and JavaScript but I have some Ideas which I would like to execute and I will learn anything and everything in the way to accomplish them... Program: user end: the page is about users priorities and displaying back the selected... the program work as a user reaction based comparison module... where the priorities stored in the program are shown 2 at a time and lets user to select what is more important to him and stores the result in another variable than that variable is shown with another variable which is already stored and the result out of that is stored in another new variable and so on.. in the end it show the result of important selected priorities... 1) say there are 6 variables storing string values: Code: <script type = "text/javascript"> var p1 = "Doctors appointment"; var p2 = "studying for the exam"; var p3 = "Going out for most awaited shopping"; var p4 = "Login on Facebook"; var p5 = "Replying to text msgs"; var p6 = "Go out with friends"; 2) there are two sections on the html document: i) where the variables are displayed dynamically and changes the value on click.. it works like a comparison where user selects (onclick) what is more important to him shows the next value and so on... in the end stores the result... functioning(I have no I idea how to do this): say on the html document only two variables are displayed at first and than the user selects one of it as more important to him so the result is stored in another new variable than that new variable is shown with the third stored variable and once one of them is selected it is stored in another new variable and is compared with forth stored variable and so on till the last selected is stored as the result1... all comparisons must happen on the same div of the html document procedure has to loop three times till 3 results (result1, result2, result3) out of six are selected more important... result1 has to be removed from the next loop for result 2 as result1 is already selected important by the user.. result1 and result2 are to be removed from the next loop for result 3 as they are already selected important by the user ii) the second section displays important 3 results (result1, result2, result3) selected by him... my friend told jQuery can do the dynamic comparison part but I don't know how to use it... the logic of creating new variable for storing result and then comparing can be improved or changed... Please help Hi im making a calculator and there is a box that returns a fraction but i can only get the decimal here is what ive got so far: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>rivet calculator</title> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"></head><body> <p style="text-align: center;"> <a href="website.html"><img style="border: 0px solid ; width: 278px; height: 50px;" alt="" src="file:///Y:/TEMP/cody%20shoemake/old%20comp%20stuff/Documents/LOGO.png"></a><font size="+2"><span style="font-family: Century Gothic;"><font style="text-decoration: underline;" size="+3"><br> Rivet Calculator<span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"></span></span></span></span></span></font></span></font><br> </p> <font size="+2"><span style="font-family: Century Gothic;"><font style="text-decoration: underline;" size="+3"><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"> </span></span></span></span></span></font></span></font> <div style="text-align: left;"><font size="+2"><span style="font-family: Century Gothic;"> </span></font> <script type="text/javascript"> // From: http://www.codingforums.com/showthread.php?p=857884#post857884 function RDcalc1() { // document.rc.ds.value="67"; // if (document.rc.ds.value=="67") { document.rc.rds.value=""; } // not a valid logical test -- what are you trying to do here??? document.rc.rds.value=''; } function RDcalc2() { document.rc.fd.value=document.rc.rds.value/32; document.rc.dd.value=(document.rc.rds.value/32).toFixed(2); document.rc.bl.value=(document.rc.rds.value/32*1.5).toFixed(2); document.rc.red.value=(document.rc.dd.value*2+1/16).toFixed(2); document.rc.med.value=(document.rc.dd.value*1.86).toFixed(2); document.rc.cdmed.value=(document.rc.dd.value*2).toFixed(2); } function RDcalc3() { document.rc.dn.value=((Number(document.rc.bl.value)+Number(document.rc.suv.value))/.0625).toFixed(2); document.rc.red.value=(document.rc.dd.value*2+1/16).toFixed(2); document.rc.med.value=(document.rc.dd.value*1.86).toFixed(2); document.rc.cdmed.value=(document.rc.dd.value*2).toFixed(2); document.rc.mrs.value=(document.rc.dd.value*4).toFixed(2); } </script> <form name="rc"> <table style="text-align: left; margin-left: auto; margin-right: auto;"> <tbody> <tr> <td> <br> </td> <td colspan="2" rowspan="1" style="text-align: left;"> Stack Up Value</td> </tr> <tr> <td style="vertical-align: top;"><br> </td> <td colspan="2" rowspan="1" style="vertical-align: top;"> <input name="suv" onkeyup="RDcalc3()" type="text"></td> </tr> <tr> <td style="vertical-align: top;"><br> </td> <td colspan="2" rowspan="1" style="vertical-align: top;"> Rivet Dash # <select name="rds" onchange="RDcalc1(this.value);RDcalc2();RDcalc3()"> <option onclick='document.rc.ds.value="67";document.rc.dsnd.value="0.0320"' selected="selected">1</option> <option onclick='document.rc.ds.value="51";document.rc.dsnd.value="0.0670"'>2</option> <option onclick='document.rc.ds.value="40";document.rc.dsnd.value="0.0980"'>3</option> <option onclick='document.rc.ds.value="30";document.rc.dsnd.value="0.1285"'>4</option> <option onclick='document.rc.ds.value="21";document.rc.dsnd.value="0.1590"'>5</option> <option onclick='document.rc.ds.value="11";document.rc.dsnd.value="0.1910"'>6</option> <option onclick='document.rc.ds.value="1";document.rc.dsnd.value="0.2280"'>7</option> <option onclick='document.rc.ds.value="F";document.rc.dsnd.value="0.2570"'>8</option> <option onclick='document.rc.ds.value="L";document.rc.dsnd.value="0.2900"'>9</option> <option onclick='document.rc.ds.value="O";document.rc.dsnd.value="0.3160"'>10</option> <option onclick='document.rc.ds.value="S";document.rc.dsnd.value="0.3480"'>11</option> <option onclick='document.rc.ds.value="V";document.rc.dsnd.value="0.3770"'>12</option> <option onclick='document.rc.ds.value="Z";document.rc.dsnd.value="0.4130"'>13</option> <option onclick='document.rc.ds.value="29/64";document.rc.dsnd.value="0.4531"'>14</option> </select> </td> </tr> <tr> <td colspan="3" rowspan="1" style="vertical-align: top;"> <hr style="width: 100%; height: 2px;"><br> </td> </tr> <tr> <td>Fraction Diameter</td> <td><input name="fd" readonly="readonly" type="text"></td><td>Buck Length <input name="bl" readonly="readonly" type="text"></td> </tr> <tr> <td>Decimal Diameter</td> <td><input name="dd" readonly="readonly" round_05up="" type="text"></td><td>Dash # <input name="dn" readonly="readonly" type="text"></td> </tr> <tr> <td>Drill Size</td> <td><input name="ds" readonly="readonly" type="text"></td><td>Recommended ED <input name="red" readonly="readonly" type="text readonly="></td> </tr> <tr> <td>Drill Size Nominal Diameter</td> <td><input name="dsnd" readonly="readonly" type="text"></td><td>Minimum ED <input name="med" input="" readonly="readonly" type="text"></td> </tr> <tr> </tr> <tr> <td>CSK/DIMPL E Minimum ED</td> <td><input name="cdmed" input="" readonly="readonly" type="text"></td><td>Multi-Row Spacing <input name="mrs" input="" readonly="readonly" type="text"></td> </tr> </tbody> </table> </form> <br> <font size="+2"><span style="font-family: Century Gothic;"></span></font></div> <font size="+2"><span style="font-family: Century Gothic;"><br> <br> <br> <br> </span></font> </body></html> Hey there, so this is my first time using this website. I was wondering if anyone can help me resolve this problem. It is for my Website Development Class and I am going use this forum to help me understand the languages haha. But Anyways. My homework assignment I have to do is: Create a Web page named gpa.html that can be used to compute your grade point average given grades and hours for courses completed. The page should repeatedly prompt the user for course information, reading the course name, grade received, and credit hours for a particular course in a single dialog box. While the user is done inputting the information, it should display on the website like this: COURSE GRADE HOURS THL100 B+ 3 PHL107 A 3 ENG120 C+ 3 MTH245 A 4 CSC221 A 3 Total grade points = 58 Number of hours = 16 GPA = 3.625 So my problem is that when I tried to display it outside the while loop it only displays "NaN". Please Help and Thanks! Here is my code: <!DOCTYPE html> <html> <!-- gpa.html--> <head> </head> <body> <script type= "text/javascript"> document.write("Course - Grade - Credit Hours"); document.write("<br>"); var third; var total = 0; var total2 = 0; var total4 = 0; var t_hrs = 0; var user; while (user != "") { user = prompt("Hello User. Enter course name, grade, & credit hours (i.e CS3240 B+ 3), or click OK with no data to terminate."); var uInput = user.split(" "); document.write(uInput); document.write("<br>"); third = uInput[2]; t_hrs = parseInt(t_hrs) + parseInt(uInput[2]); if (uInput[1] == "A"){ letter2point = 4.0; } else if (uInput[1] == "B+"){ letter2point = 3.5; } else if (uInput[1] == "B"){ letter2point = 3.0;} else if (uInput[1] == "C+"){ letter2point = 2.5; } else if (uInput[1] == "C"){ letter2point = 2.0; } else if (uInput[1] == "D"){ letter2point = 1.0; } else if (uInput[1] == "F"){ letter2point = 0.0; } total = letter2point * third; total2 = total2 + total; total4 = total2 / t_hrs; } document.write(total4) </script> </body> </html> Reply With Quote 01-29-2015, 02:47 AM #2 felgall View Profile View Forum Posts Visit Homepage Master Coder Join Date Sep 2005 Location Sydney, Australia Posts 6,745 Thanks 0 Thanked 666 Times in 655 Posts If that antiquated JavaScript is what your course is teaching then I feel sorry for you. Just about every statement that you have there is listed on one of the "Bad Bits" pages of my Introducing JavaScript web site where it gives the reasons for not using those 20 year old code constructs in modern web browsers (which means IE5 and any browser more recent than that). A couple of suggestions to get you started. 1. The second document.write is not complete so everything from there onward is broken. 2. To convert to a number use Number((t_hrs) or (+t_hrs). If you must use parseint then always include the second parameter to specify the number base you are converting from parseInt(t_hrs, 10) - with regard to t_hrs it is a number to start with so doesn't even need this conversion. 3. Use === and !== instead of == and != as the two character versions don't always give the expected result where the three character versions always do. Hi all - I'm designing a website, and I need to have a search button allow users to search the inventory that is on the website. I'm not quite sure what code I'm going to use for the search button, but I imagine that I can work on that sometime.. Along with the code, am I required to have something such as a MySQL database set-up or something of the sort? This question may be mis-categorized, so please let me know if it is. Thanks everyone! |