JavaScript - 3 > 17 - Unexpected Result
Hi there,
i have a dynamic form that is populated via a sql query (WHERE $AVAILABLE_PRODUCT > 0) hence the javascript that is called onchange has dynamic field names. i used numbers. the for loop works fine: Code: var numberOfFields = document.order_form.elements.length; for (var i=1; i<numberOfFields-3; i=i+4) { if (document.order_form.elements[i].value > document.order_form[i+3].value) { alert(document.order_form.elements[i].value + ' > ' + document.order_form[i+3].value); } .... } Alert Box shows: 3 > 17 or similar (where 17 is the number of items on stock, and three the number of items ordered.) all other calculations with that form work fine. any idea? Similar TutorialsHello, I do not have a lot of experience with Java and my HTML skills have not been put to use in a few years. The problem that I am having is trying to call a .js from an IIS footer file. The script is Code: <!-- Piwik --> <script type="text/javascript"> var pkBaseURL = (("https:" == document.location.protocol) ? "https://216.128.27.18/" : "http://216.128.27.18/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); </script><script type="text/javascript"> try { var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 25); piwikTracker.trackPageView(); piwikTracker.enableLinkTracking(); } catch( err ) {} </script><noscript><p><img src="http://216.128.27.18/piwik.php?idsite=25" style="border:0" alt="" /></p></noscript> <!-- End Piwik Tracking Code --> When added directly to the <body></body> of the html it works but i want to append it to all pages with a footer. I created an piwik.js with that above code then made an html file with Code: <script src="piwikfooter.js" type="text/javascript"></script> It does try to call the script but I get an error when loading the site piwikfooter.js:2Uncaught SyntaxError: Unexpected token< Any help would be very much appreciated. Hello i'm using TinyceEditor in my website and i'm using AjaxFileManager to upload images. It works very good in my localhost, but in the remote server while uploading image an error appears (" Syntaxerror: unexpected token < ") and uploading stop. please i need the answer quickly Ok, so I wanted to use the following object to copy the contents of the Report array at index [file][entry]. Code: Selected = { fileIndex : file, entryIndex : entry, Entry : Report[file][entry] } This was done so that the user may perform modifications to the entry without updating the entry until I have run validation on the input. Then I used Code: if(valid) Report[Selected.fileIndex][Selected.entryIndex] = Selected.Entry to finish up. I noticed that the Report array was getting the new input even when I didn't validate. I used the following to view all the contents of the Report Array in real time Code: window.setInterval('SHOW_ARRAY();',200); Report=[]; function SHOW_ARRAY(){ HTML('ReportDebug','') //Reset "ReportDebug" HTML element for(var t in Report){ for(var y in Report[t]){ for(var u in Report[t][y]){ HTML('ReportDebug','<span style="position:relative ; border:2px solid black">'+Report[t][y][u]+'</span>',1) // last argument signifies to append HTML element } } HTML('ReportDebug','<br />',1) } } And what I discovered was that whenever I stored values in Selected.Entry the Report array would update with those values! This is my first attempt to create an object in this fashion, so my only guess is that Selected.Entry is not independent from Report[file][entry], but instead some kind of pointer... Where have I gone wrong, and how can I accomplish my goal? Let me know if my code samples were too brief. Hey all, I have a rather complicated program so I'm going to try and make it a little simpler - the problem is with the following function: Code: this.onInsertSuccess = function (paramsArray) { var result = Array(); result[0] = {}; result[0][this.params.idfield] = paramsArray.id; result[0][this.params.titlefield] = "NEW ITEM"; result[0][this.params.displayfield] = 1; console.log(this.displayArray.length); for (x = 0; x < this.displayArray.length; x++) { this.displayArray[x][this.params.displayfield] = x + 2; result[result.length] = this.displayArray[x]; newParams = {idfield:this.params.idfield, id:this.displayArray[x][this.params.idfield], table:this.params.table, displayfield:this.params.displayfield, order:(x+2)}; this.load.updateItem(newParams); } this.displayArray = Array(); for (x = 0; x < result.length; x++) { this.displayArray[x] = result[x]; } this.display(); } Here's a simplified version: Code: onInsertSuccess = function (id) { var result = Array(); result[0] = {}; result[0][this.params.idfield] = id; result[0][this.params.titlefield] = "NEW ITEM"; result[0][this.params.displayfield] = 1; for (x = 0; x < this.displayArray.length; x++) { this.displayArray[x].displayorder = x + 2; result[result.length] = this.displayArray[x]; } this.displayArray = result; // this just updates the display and has no effect on displayArray this.display(); } What's happening is that the first time this is called, displayArray appears to update correctly and a "NEW ITEM" appears at the top of my list. The next time the function is called, displayArray consists of only two results - each "NEW ITEM" - this continues to be the case when the function is called again. the initial displayArray is this: Code: this.displayArray = [{'clid': "1", 'name': "Yorkshire Digital Awards", 'displayorder': "1"}, {'clid': "2", 'name': "Screen Yorkshire", 'displayorder': "2"}, {'clid': "3", 'name': "SureStart Selby District", 'displayorder': "3"}, {'clid': "4", 'name': "Mencap", 'displayorder': "4"}, {'clid': "5", 'name': "York St. Johns", 'displayorder': "5"}, {'clid': "6", 'name': "Mobstar Media", 'displayorder': "6"}, {'clid': "7", 'name': "Wheatfields Hospice", 'displayorder': "7"}, {'clid': "8", 'name': "The National Railway Museum", 'displayorder': "8"}]; I've left the original function in because I fully appreciate that it may be another function that's causing this problem! I thought also it could be to do with accidentally assigning references rather than values (hence the adaption of the result assignment at the end of the function in the full code). Any ideas? Many thanks Edd to see the unexpected page shift in action go to http://lawlocaust.net/gamerverse/ while hovering over the banner u can use the arrow keys to navigate the UI and the page will shift in firefox HTML 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" xml:lang="en" lang="en"> <head> <title>GamerVerse</title> <link rel="stylesheet" type="text/css" href="<?php echo $domain; ?>gamerverse.css" /> <?php include('children.php'); ?> <script type="text/javascript" src="gamerverse.js"> </script> </head> <?php include('top.php'); ?> top.php Code: <body onload="javascript: initialize()"> <div id="bgimgwrap"> <img id="bgimg" src="<?php echo $domain; ?>mainbg.jpg" alt="" /> </div> <div id="cursor"> </div> <div class="header" id="header" onmouseover="activatekeys()" onmouseout="deactivatekeys()"> <div class="menu"> <ul> <li><a href="#" onclick="javascript: jumpto(0)">Home</a></li> <li><a href="#" onclick="javascript: jumpto(1)">Users</a></li> <li><a href="#" onclick="javascript: jumpto(2)">Games</a></li> <li><a href="#" onclick="javascript: jumpto(3)">New Stuff</a></li> <li><a href="#" onclick="javascript: jumpto(4)">Forum</a></li> <li><a href="#" onclick="javascript: jumpto(5)">Guilds</a></li> <li><a href="#" onclick="javascript: jumpto(6)">Store</a></li> </ul> <div style="float: right; width: 100px;"> X: <span id="myx"> </span> Y: <span id="myy"> </span> </div> </div> <div class="childarea"> <div id="child0"><a href="#" onclick="">child0</a><a href="#" onclick="">child1</a></div> <div id="child1"><a href="#" onclick="">child1</a><a href="#" onclick="">child1</a></div> <div id="child2"><a href="#" onclick="">child2</a><a href="#" onclick="">child1</a></div> <div id="child3"><a href="#" onclick="">child3</a><a href="#" onclick="">child1</a></div> <div id="child4"><a href="#" onclick="">child4</a><a href="#" onclick="">child1</a></div> <div id="child5"><a href="#" onclick="">child5</a><a href="#" onclick="">child1</a></div> <div id="child6"><a href="#" onclick="">child6</a><a href="#" onclick="">child1</a></div> </div> <img src="<?php echo $domain; ?>banner.png" alt="" /> </div> <div class="page" id="page"> <table cellspacing="0px"; cellpadding="0px" id="main"> <tr> <td><div><?php include('home.php'); ?></div></td><td><div><?php include('users.php'); ?></div></td><td><div><?php include('games.php'); ?></div></td><td><div><?php include('new.php'); ?></div></td><td><div><?php include('forum.php'); ?></div></td><td><div><?php include('guilds.php'); ?></div></td><td><div><?php include('store.php'); ?></div></td> </tr> </table> </div> <div id="child"><div id="kid0"><?php echo $homekid; ?></div><div id="kid1"><?php echo $userskid; ?></div><div id="kid2"><?php echo $gameskid; ?></div><div id="kid3"><?php echo $newkid; ?></div><div id="kid4"><?php echo $forumkid; ?></div><div id="kid5"><?php echo $guildskid; ?></div><div id="kid6"><?php echo $storekid; ?></div></div> CSS Code: body { background: black; color: white; width: 100%; height: 100%; overflow: hidden; } * { padding: 0px; margin: 0px; } #bgimgwrap { position: absolute; z-index: 1; top: 0; left: 0; } .header { position: absolute; left: 0; top: 0; width: 100%; z-index: 2; text-align: center; } .menu { width: 100%; text-align: center; margin: auto; padding: 0px 0px 4px 0px; } .menu li { display: inline; margin-left: 0px; float: left; } .menu a { display: block; width: 100px; height: 20px; line-height: 20px; color: white; text-decoration: none; margin-left: 0px; border-bottom: 1px solid white; border-right: 1px solid white; } .menu a:hover { color: black; } .page { position: absolute; left: 0; } #cursor { display: block; position: absolute; top: 0; width: 100px; height: 20px; background: red; opacity:0.4; filter:alpha(opacity=40); z-index: 11; } td { overflow: hidden; background: #6faae4 url(right.png) repeat-y 100% 0%; padding: 0px 25px 0px 25px; } td:before { display: block; content: url(topleft.png); background: url(topright.png) no-repeat 100% 0%; height: 25px; margin: 0px -25px 0px -25px; } td:after { display: block; content: url(bottomleft.png); background: url(bottomright.png) no-repeat 100% 0%; height: 25px; margin: 0px -25px 0px -25px; } td div:first-child { background: #3d74aa; border: 4px outset #c6c6c6; overflow: hidden; } #child { position: absolute; left: 0px; width: 100%; } #kid0 { display: none; } #kid1 { display: none; } #kid2 { display: none; } #kid3 { display: none; } #kid4 { display: none; } #kid5 { display: none; } #kid6 { display: none; } .childarea { width: 100%; height: 20px; margin-top: 17px; } .childarea div { display: none; } .childarea a { display: inline-block; width: 100px; height: 20px; line-height: 20px; color: white; text-decoration: none; margin-left: 0px; border-bottom: 1px solid white; border-right: 1px solid white; } .childarea a:hover { color: black; } #child0 { position: absolute; left: 0px; } #child1 { position: absolute; left: 101px; } #child2 { position: absolute; left: 202px; } #child3 { position: absolute; left: 303px; } #child4 { position: absolute; left: 404px; } #child5 { position: absolute; left: 505px; } #child6 { position: absolute; left: 606px; } javascript Code: //sets the global variables function initialize() { //alert(navigator.appName+' '+navigator.appCodeName+' '+navigator.appVersion); window.bgimg = document.getElementById('bgimg'); window.bgimgwrap = document.getElementById('bgimgwrap'); window.header = document.getElementById('header'); window.page = document.getElementById('page'); window.main = document.getElementById('main'); window.child = document.getElementById('child'); window.cursor = document.getElementById('cursor'); window.childqty = new Array(); window.childqty[0] = 2 - 1; window.childqty[1] = 2 - 1; window.childqty[2] = 2 - 1; window.childqty[3] = 2 - 1; window.childqty[4] = 2 - 1; window.childqty[5] = 2 - 1; window.childqty[6] = 2 - 1; get_dims(); } //adjusts various elements to make the site fluid function get_dims() { winH = getH(); winW = getW(); bgimg.width = header.offsetWidth; bgimg.height = header.offsetHeight; bgimgwrap.width = header.offsetWidth; bgimgwrap.height = header.offsetHeight; var h = header.offsetHeight; page.style.top = h+"px"; main.style.width = (winW*7)+"px"; child.style.top = winH+"px"; child.height = (winH-h)+"px"; var td = document.getElementsByTagName('td'); for(i = 0; i < td.length; i++) { td[i].width = winW+"px"; td[i].style.height = (winH-h)+"px"; td[i].firstChild.style.height = ((winH-h)-58)+"px"; td[i].firstChild.style.width = ((winW - (td[i].firstChild.offsetLeft*2))-8)+"px"; } } //gets the height of the window function getH() { var winH = 0; if (navigator.appName.indexOf("Microsoft")!=-1) { winH = document.documentElement.clientHeight; } else { winH = window.innerHeight; } return winH; } //gets the width of the window function getW() { var winW = 0; if (navigator.appName.indexOf("Microsoft")!=-1) { winW = document.documentElement.clientWidth; } else { winW = window.innerWidth; } return winW; } //the keydown action script function move(c) { c = c || window.Event; var k = c.which; if(!k) { var k = c.charCode; } if(!k) { var k = c.keyCode; } var winW = getW(); var winH = getH(); var h = header.offsetHeight; winH = winH - h; switch(k) { case 37: var thing = pos_check(); if(thing == "parent") { if(page.offsetLeft != 0) { slide('right', 0); cursormove('right', 0); } } else { slidekid('right', 0); } break; case 38: var thing = pos_check(); if(thing == "child"){ ditchkids(); } break; case 39: var thing = pos_check(); if(thing == "parent") { if(page.offsetLeft != -(winW*6)) { slide('left', 0); cursormove('left', 0); } } else { slidekid('left', 0); } break; case 40: var thing = pos_check(); if(thing == "parent"){ getkids(); } break; case 116: window.location.reload(); break; default: break; } } //move the page left or right function slide(dir, i) { var w = getW(); if(i < w) { switch(dir) { case 'left': page.style.left = (page.offsetLeft - 8)+"px"; break; case 'right': page.style.left = (page.offsetLeft + 8)+"px"; break; } i++; i++; i++; i++; i++; i++; i++; i++; var t = setTimeout("slide('"+dir+"', '"+i+"')", 0); } if(page.offsetLeft > 0){ page.style.left = 0+"px"; } if(page.offsetLeft < -(w*6)){ page.style.left = -(w*6)+"px"; } } //moves the cursor left or right function cursormove(dir, i) { switch(dir) { case 'left': cursor.style.left = (cursor.offsetLeft + 1)+"px"; break; case 'right': cursor.style.left = (cursor.offsetLeft - 1)+"px"; break; } if(i < 100) { i++; setTimeout("cursormove('"+dir+"', '"+i+"')", 20); } if(cursor.offsetLeft < 0){ cursor.style.left = 0+"px"; } if(cursor.offsetLeft > 606){ cursor.style.left = 606+"px"; } } //checks to see which set of elements ur looking at function pos_check() { var h = header.offsetHeight; if(page.offsetTop == h) { return "parent"; } else { return "child"; } } //displays the child elements function getkids() { var c = cursor.offsetLeft; c = c/101; winW = getW(); p = childqty[c]; document.getElementById(c+'child').style.width = (winW*(p+1))+"px"; document.getElementById('child'+c).style.display = "block"; document.getElementById('kid'+c).style.display = "block"; child.style.left = 0+"px"; raisekid('up', 0); } function raisekid(d, i) { switch(d) { case "up": page.style.top = (page.offsetTop - 2)+"px"; child.style.top = (child.offsetTop - 2)+"px"; break; case "down": page.style.top = (page.offsetTop + 2)+"px"; child.style.top = (child.offsetTop + 2)+"px"; if(i >= page.offsetHeight) { hidekids(); } break; } if(i < page.offsetHeight) { i++; i++; setTimeout("raisekid('"+d+"', '"+i+"')", 0); } if(page.offsetTop > header.offsetHeight){ page.style.top = header.offsetHeight+"px"; } } function ditchkids() { raisekid('down', 0); } function hidekids() { var c = cursor.offsetLeft; c = c/101; document.getElementById('child'+c).style.display = "none"; document.getElementById('kid'+c).style.display = "none"; } //moves the shild pages left or right function slidekid(dir, i) { var w = getW(); if(i < w) { switch(dir) { case 'left': child.style.left = (child.offsetLeft - 8)+"px"; break; case 'right': child.style.left = (child.offsetLeft + 8)+"px"; break; } i++; i++; i++; i++; i++; i++; i++; i++; var t = setTimeout("slidekid('"+dir+"', '"+i+"')", 0); } var c = cursor.offsetLeft; c = c/101; p = childqty[c]; if(child.offsetLeft > 0){ child.style.left = 0+"px"; } if(child.offsetLeft < -(w*p)){ child.style.left = -(w*p)+"px"; } } //turns on the UI when hovering over the banner function activatekeys() { document.addEventListener('keydown', move, true); } //turns off the UI when u stop hovering function deactivatekeys() { document.removeEventListener('keydown', move, true); } I will tell you now that I am not a javascript programmer and this is a very basic question. Please don't flame. I have been writing a web site and have found 2 functions that work and do what I want them to do, but I want to combine them. The first function will grab the window size.(it actually prints it out to the screen and I know how to get that to stop by taking out the last 2 lines) What I want to do with the results from the function alertSize() is exactly what the function res() does though. I want it to take the window size and jump to the appropriate web directory. What I don't know is if I can write that all as one function or if I have to pass the results of function alertSize() to function res(). Or how to do it for that matter, I don't even know what this is called in programming lingo. I am not asking for an answer here I would just like someone to point me in the right direction that I may learn a little more about what it is I want to do so I can get this to work. Giving me a search term would be a BIG help. Here is the first function. Code: // <script language="JavaScript"> //--> function alertSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } window.alert( 'width = ' + myWidth ); window.alert( 'height = ' + myHeight ); } // </script> //--> and the second function. Code: // <script language="JavaScript"> //--> function res() { alert('Screen Resolution Is '+screen.width+' by '+screen.height); } if ((screen.width>=1280) && (screen.height>=1024)) { window.location="/12/index.html"; } else if ((screen.width>=1024) && (screen.height>=768)) { window.location="/10/index.html"; } else if ((screen.width>=800) && (screen.height>=600)) { window.location="lowres1.html"; } else if ((screen.width>=640) && (screen.height>=480)) { window.location="lowres2.html"; } else { window.location="lowres3.html"; } // </script> //--> I am trying to compare dates to see if they are equal, one date is passed to my function from a calendar. alert(mydate); returns "Tue Dec 22 10:00:00 EST 2009" My date that I need to compare is written dynamically out of a database and it is formatted as a string: 2009-12-22 One might think that (Date(2009-12-22) == mydate) would be true, except the time is also included ... thus it is false, but if I try to use something like this: Code: var dd = new Date(2009-12-22); if(dd.toDateString == mydate.toDateString) ...dostuff ... the dates don't equal ... and I subsequently find out that dd.toDateString actually returns "Fri Jan 22 2010" when I explicitly passed 2009-12-22 to the function. I'd simply like to compare the dates to determine if they are equal so I can pass a return value back to the calendar. The code that works, effectively returning false on all Tuesdays after today is: Code: function disallowDate(d) { var today = new Date(); if (d.getDay() == 2 && (d > today)) return false; return true; } Now I need to determine if any date selected previously is available, so I have to read them out of the database and write them dynamically to the script. Right now I have something like this, but obviously it doesn't work. Code: function disallowDate(d) { var today = new Date(); if (d == Date(2009-12-29)) return true; //this lines is written dynamically if (d == Date(2009-12-22)) return true; //this lines is written dynamically if (d.getDay() == 2 && (d >= today)) return false; return true; } thanks! Hello ! I am trying to create an auto suggest drop down. I have some ASP and Javascript code that I am using as an Autosuggest. Trouble is, the result displays on the main page, not under the text box like a drop down menu. I need help in getting the results to display correctly underneath the textbox. I have trawlled the internet and have loads and loads of code samples but I cant see the wood for the trees and I am really struggling with editing this code so that it displays correctly. clienthint.asp Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <html> <head> <script src="clienthint.js"></script> </head> <body> <% 'this displays the value of the textbox after the form is submitted If trim(Request("txt1")) <> "" Then Response.Write "You entered:" Response.Write "<b>" & Request("txt1") & "</b><br /><br />" End If %> <form name="form1" action="clienthint.asp" method="post"> Enter Word: <input type="text" name="txt1" id="txt1" onKeyUp="showHint(this.value,'txt1','form1',true)"> <input type="submit" name="submit" value="submit"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> clienthint.js Code: var xmlHttp function showHint(str, box, thisForm, autoSubmit) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="gethint.asp"; url=url+"?q="+str; url=url+"&b="+box; url=url+"&f="+thisForm; url=url+"&a="+autoSubmit; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } //this function allows for Clickable suggestions function setTextBox(thisText,thisBox,thisForm,autoSubmit){ document.getElementById(thisBox).value = thisText //this autoSubmits the form after a suggestion is clicked - it is not working :( //if(autoSubmit=='true'){ // alert(thisForm); // document.getElementById(thisForm).submit(); //} } gethint.asp Code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% response.expires=-1 Dim rsWords Dim rsWords_numRows Dim q Dim b Dim hint q=ucase(request.querystring("q")) b=(request.querystring("b")) f=(request.querystring("f")) a=(request.querystring("a")) hint="" Set rsWords = Server.CreateObject("ADODB.Recordset") rsWords.ActiveConnection = "Provider=SQLOLEDB; Data Source=JAGUAR\SQLEXPRESS; Initial Catalog=67625252; User ID=SFSDFSDF; Password=KJHSDHFJHDF" rsWords.Source = "SELECT * FROM Rmatable WHERE (RMA_ID LIKE'" + q + "%') ORDER BY RMA_ID" rsWords.CursorType = 2 rsWords.CursorLocation = 2 rsWords.LockType = 3 rsWords.Open() rsWords_numRows = 0 If Not rsWords.EOF Then Do While Not rsWords.EOF If trim(hint) = "" Then hint = "<a href=""javascript:setTextBox('" & rsWords("RMA_ID") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("RMA_ID") & "</a>" Else hint = hint & " , <a href=""javascript:setTextBox('" & rsWords("RMA_ID") & "','" & b & "','" & f & "','" & a & "');"">" & rsWords("RMA_ID") & "</a>" End If rsWords.MoveNext() Loop End If if trim(hint)="" then response.write("no suggestion") else response.write(hint) end if rsWords.Close() Set rsWords = Nothing %> I am trying to set up a small legend type html. What I am trying to accomplish is to give the user a description depending on the abbv they pick from the drop down. This all works fine, however I now want to improve this to actually give them a link to a site if they want to research the description further. I can get it to work if I do document.write but I want the link to go into the text box. I also thought about making a button to the side that would probably need some sort of function to call each url. That may come down the road but the simpler way would be nice. I have a js called abbs there is actually two ways to do the drop downs but I am only concerned with adding links to the top one. On the CCVT option I have added a link but the only way I can get it to work is through document.write. Here is my JS code: Code: function findMEAN(){ var abb = document.listNAME.abbWRD.value; if (abb == "AEP"){ abbs = ("American Electric Power") ;} else if (abb == "A"){ abbs = ("AMP") ;} else if (abb == "AC"){ abbs = ("ALTERNATING CURRENT") ;} else if (abb == "ACI"){ abbs = ("AMERICAN CONCRETE INSTITUTE") ;} else if (abb == "ACB"){ abbs = ("AIR CIRCUIT BREAKER") ;} else if (abb == "AISC"){ abbs = ("AMERICAN INSTITUTE OF STEEL CONSTRUCTION") ;} else if (abb == "ANSI"){ abbs = ("AMERICAN NATIONAL STANDARDS INSTITUTE") ;} else if (abb == "ARO"){ abbs = ("AUTOMATIC RECLOSING OPERATION") ;} else if (abb == "ASCE"){ abbs = ("AMERICAN SOCIETY OF CIVIL ENGINEERS") ;} else if (abb == "ASTM"){ abbs = ("AMERICAN SOCIETY FOR TESTING AND MATERIAL") ;} else if (abb == "AUX"){ abbs = ("AUXILUARY") ;} else if (abb == "AWG"){ abbs = ("AMERICAN WIRE GAUGE") ;} else if (abb == "BCT"){ abbs = ("BUSHING CURRENT TRANSFORMER") ;} else if (abb == "BIL"){ abbs = ("BASIC INSULATION LEVEL") ;} else if (abb == "BOM"){ abbs = ("BILL OF MATERIAL") ;} else if (abb == "BPD"){ abbs = ("BUSHING POTENTIOAL DEVICE") ;} else if (abb == "BPLC"){ abbs = ("BROADBAND POWER LINE CARRIER") ;} else if (abb == "BT"){ abbs = ("BUS TIE") ;} else if (abb == "CAB"){ abbs = ("CABLE") ;} else if (abb == "CAT#"){ abbs = ("CATALOG NUMBER") ;} else if (abb == "CB"){ abbs = ("CIRCUIT BREAKER") ;} else if (abb == "CCVT"){ abbs = ("COUPLING CAPACITOR VOLTAGE TRANSFORMER") ; abbslnk = "<p>Link: " + abbs.link("http://www.abb.com/product/db0003db002618/c12573e7003302adc1256ffd001d1256.aspx") + "</p>";} else if (abb == "CS"){ abbs = ("CIRCUIT SWITCHER") ;} else if (abb == "CT"){ abbs = ("CURRENT TRANSFORMER") ;} else if (abb == "CVT"){ abbs = ("CAPACITOR VOLTAGE TRANSFORMER") ;} else if (abb == "DC"){ abbs = ("DIRECT CURRENT") ;} else if (abb == "DEB"){ abbs = ("DOUBLE END BREAK") ;} else if (abb == "DMS"){ abbs = ("DATA MANAGEMENT SYSTEM/DIGITAL METERING SYSTEM") ;} else if (abb == "FDN"){ abbs = ("FOUNDATION") ;} else if (abb == "FMP"){ abbs = ("FIELD MARKED PRINT") ;} else if (abb == "GIS"){ abbs = ("GAS INSULATED SYSTEM") ;} else if (abb == "GND,GRDG"){ abbs = ("GROUND(ING)") ;} else if (abb == "GOAB"){ abbs = ("GAS OPREATED AIR BREAK") ;} else if (abb == "GOS"){ abbs = ("GANG OPREATED SWITCH") ;} else if (abb == "IFC"){ abbs = ("ISSUE FOR CONSTRUCTION") ;} else if (abb == "KA"){ abbs = ("KILO AMP") ;} else if (abb == "KCM"){ abbs = ("KILO(1000) CIRCULAR-MILS") ;} else if (abb == "KV"){ abbs = ("KILOVOLT") ;} else if (abb == "KVAR"){ abbs = ("KILOVOLT-AMPERES REACTIVE") ;} else if (abb == "LTC"){ abbs = ("LOAD TAP CHANGER") ;} else if (abb == "MLSE"){ abbs = ("MOST LIMITING SIGNIFICANT ELEMENT") ;} else if (abb == "MOAB"){ abbs = ("MOTOR OPERATED AIR BREAK") ;} else if (abb == "MOD"){ abbs = ("MOTOR OPERATED DISCONNECT") ;} else if (abb == "MR"){ abbs = ("MATERIAL REQUEST") ;} else if (abb == "MVAR"){ abbs = ("MEGAVOLT AMPERE REACTIVE") ;} else if (abb == "N.C."){ abbs = ("NORMALLY CLOSED") ;} else if (abb == "N.O."){ abbs = ("NORMALLY OPEN") ;} else if (abb == "NEMA"){ abbs = ("NATIONAL ELECTRICAL MANUFACTURER\'S ASSOCIATION") ;} else if (abb == "OCB"){ abbs = ("OIL CIRCUIT BREAKER") ;} else if (abb == "OEC"){ abbs = ("OUTSOURCED ENGINEERING COMPANY") ;} else if (abb == "OLD"){ abbs = ("ONE LINE DIAGRAM") ;} else if (abb == "OSHA"){ abbs = ("OCCUPATIONAL SAFETY AND HEALTH ADMINISTRATION") ;} else if (abb == "P&C"){ abbs = ("PROTECTION & CONTROL") ;} else if (abb == "PCIS"){ abbs = ("PROTECTION AND CONTROL INFORMATION SYSTEM") ;} else if (abb == "PCSS"){ abbs = ("PROTECTION & CONTROL SUPPORT SERVICES") ;} else if (abb == "PED"){ abbs = ("PROTECTION EXECUTION DOCUMENT") ;} else if (abb == "POP"){ abbs = ("PHASE OVER PHASE") ;} else if (abb == "PRA"){ abbs = ("PROJECT ROUTING & APPROVAL") ;} else if (abb == "PT"){ abbs = ("POTENTIAL TRANSFORMER") ;} else if (abb == "RIM"){ abbs = ("RELAY INSTRUMENTATION & METERING") ;} else if (abb == "RMS"){ abbs = ("ROOT MEAN SQUARE") ;} else if (abb == "RPA"){ abbs = ("R(TU) POINT ASSIGNMENT") ;} else if (abb == "RTU"){ abbs = ("REMOTE TERMINAL UNIT") ;} else if (abb == "S/N"){ abbs = ("SERIAL NUMBER") ;} else if (abb == "SA"){ abbs = ("SURGE ARRESTOR") ;} else if (abb == "SCADA"){ abbs = ("SUPERVISORY CONTROL AND DATA ACQUISITION") ;} else if (abb == "XF"){ abbs = ("TRANSFORMER") ;} else if (abb == "WD"){ abbs = ("WIRING DIAGRAM") ;} else if (abb == "VCB"){ abbs = ("VACUUM CIRCUIT BREAKER") ;} else if (abb == "V"){ abbs = ("VOLT") ;} else if (abb == "TCR"){ abbs = ("TRANSMISSION CONSTRUCTION REPRESENTATIVE") ;} else if (abb == "SW"){ abbs = ("SWITCH") ;} else if (abb == "SOW"){ abbs = ("SCOPE OF WORK") ;} else if (abb == "SESS"){ abbs = ("STATION ENGINEERING SUPPORT SERVICES") ;} { var result=document.getElementById("resultbox"); result.value = abbslnk } Here is my HTML code: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>ACRONYMS</title> <script type= "text/javascript" src="abbs.js"> </script> <style type="text/css" media="Screen"> fieldset { border: 5px solid #555555; padding: 20px; width:350px; word-wrap: normal; } </style> </head> <body> <fieldset style="width:410px; height: 250px"> <h2>DESCRIPTION BY ABBV</h2> <form name = "listNAME"> <select name="abbWRD"> <option value=A>A</option> <option value=AC>AC</option> <option value=ACB>ACB</option> <option value=ACI>ACI</option> <option value=AEP>AEP</option> <option value=AISC>AISC</option> <option value=ANSI>ANSI</option> <option value=ARO>ARO</option> <option value=ASCE>ASCE</option> <option value=ASTM>ASTM</option> <option value=AUX>AUX</option> <option value=AWG>AWG</option> <option value=BCT>BCT</option> <option value=BIL>BIL</option> <option value=BOM>BOM</option> <option value=BPD>BPD</option> <option value=BPLC>BPLC</option> <option value=BT>BT</option> <option value=CAB>CAB</option> <option value=CAT#>CAT#</option> <option value=CB>CB</option> <option value=CCVT>CCVT</option> <option value=CS>CS</option> <option value=CT>CT</option> <option value=CVT>CVT</option> <option value=DC>DC</option> <option value=DEB>DEB</option> <option value=DMS>DMS</option> <option value=FDN>FDN</option> <option value=FMP>FMP</option> <option value=GIS>GIS</option> <option value=GND,GRDG>GND,GRDG</option> <option value=GOAB>GOAB</option> <option value=GOS>GOS</option> <option value=IFC>IFC</option> <option value=KA>KA</option> <option value=KCM>KCM</option> <option value=KV>KV</option> <option value=KVAR>KVAR</option> <option value=LTC>LTC</option> <option value=MLSE>MLSE</option> <option value=MOAB>MOAB</option> <option value=MOD>MOD</option> <option value=MR>MR</option> <option value=MVAR>MVAR</option> <option value=N.C.>N.C.</option> <option value=N.O.>N.O.</option> <option value=NEMA>NEMA</option> <option value=OCB>OCB</option> <option value=OEC>OEC</option> <option value=OLD>OLD</option> <option value=OSHA>OSHA</option> <option value=P&C>P&C</option> <option value=PCIS>PCIS</option> <option value=PCSS>PCSS</option> <option value=PED>PED</option> <option value=POP>POP</option> <option value=PRA>PRA</option> <option value=PT>PT</option> <option value=RIM>RIM</option> <option value=RMS>RMS</option> <option value=RPA>RPA</option> <option value=RTU>RTU</option> <option value=S/N>S/N</option> <option value=SA>SA</option> <option value=SCADA>SCADA</option> <option value=SESS>SESS</option> <option value=SOW>SOW</option> <option value=SW>SW</option> <option value=TCR>TCR</option> <option value=V>V</option> <option value=VCB>VCB</option> <option value=WD>WD</option> <option value=XF>XF</option> </select> </form><br> <input value="Click for Description" onclick="findMEAN()" type="button"> </br></br> <input type="text" name="myresultbox" id="resultbox" style="width:400px; height:75px;"> </fieldset><br> <fieldset style="width:350px; height: 250px"> <h2>ABBV BY DESCRIPTION</h2> <form name = "listDESC"> <select name="abbABB"> <option value=A>AMP</option> <option value=AC>ALTERNATING CURRENT</option> <option value=ACB>AIR CIRCUIT BREAKER</option> <option value=ACI>AMERICAN CONCRETE INSTITUTE</option> <option value=AEP>AMERICAN ELECTRICAL POWER</option> <option value=AISC>AMERICAN INSTITUTE OF STEEL CONSTRUCTION</option> <option value=ANSI>AMERICAN NATIONAL STANDARDS INSTITUTE</option> <option value=ARO>AUTOMATIC RECLOSING OPERATION</option> <option value=ASCE>AMERICAN SOCIETY OF CIVIL ENGINEERS</option> <option value=ASTM>AMERICAN SOCIETY FOR TESTING AND MATERIAL</option> <option value=AUX>AUXILUARY</option> <option value=AWG>AMERICAN WIRE GAUGE</option> <option value=BCT>BUSHING CURRENT TRANSFORMER</option> <option value=BIL>BASIC INSULATION LEVEL</option> <option value=BOM>BILL OF MATERIAL</option> <option value=BPD>BUSHING POTENTIOAL DEVICE</option> <option value=BPLC>BROADBAND POWER LINE CARRIER</option> <option value=BT>BUS TIE</option> <option value=CAB>CABLE</option> <option value=CAT#>CATALOG NUMBER</option> <option value=CB>CIRCUIT BREAKER</option> <option value=CCVT>COUPLING CAPACITOR VOLTAGE TRANSFORMER</option> <option value=CS>CIRCUIT SWITCHER</option> <option value=CT>CURRENT TRANSFORMER</option> <option value=CVT>CAPACITOR VOLTAGE TRANSFORMER</option> <option value=DC>DIRECT CURRENT</option> <option value=DEB>DOUBLE END BREAK</option> <option value=DMS>DATA MANAGEMENT SYSTEM/DIGITAL METERING SYSTEM</option> <option value=FDN>FOUNDATION</option> <option value=FMP>FIELD MARKED PRINT</option> <option value=GIS>GAS INSULATED SYSTEM</option> <option value=GND,GRDG>GROUND(ING)</option> <option value=GOAB>GAS OPREATED AIR BREAK</option> <option value=GOS>GANG OPREATED SWITCH</option> <option value=IFC>ISSUE FOR CONSTRUCTION</option> <option value=KA>KILOAMP</option> <option value=KCM>KILO(1000) CIRCULAR-MILS</option> <option value=KV>KILOVOLT</option> <option value=KVAR>KILOVOLT-AMPERES REACTIVE</option> <option value=LTC>LOAD TAP CHANGER</option> <option value=MLSE>MOST LIMITING SIGNIFICANT ELEMENT</option> <option value=MOAB>MOTOR OPERATED AIR BREAK</option> <option value=MOD>MOTOR OPERATED DISCONNECT</option> <option value=MR>MATERIAL REQUEST</option> <option value=MVAR>MEGAVOLT-AMPERES REACTIVE</option> <option value=N.C.>NORMALLY CLOSED</option> <option value=N.O.>NORMALLY OPEN</option> <option value=NEMA>NATIONAL ELECTRICAL MANUFACTURER'S ASSOCIATION</option> <option value=OCB>OIL CIRCUIT BREAKER</option> <option value=OEC>OUTSOURCED ENGINEERING COMPANY</option> <option value=OLD>ONE LINE DIAGRAM</option> <option value=OSHA>OCCUPATIONAL SAFETY AND HEALTH ADMINISTRATION</option> <option value=P&C>PROTECTION AND CONTROL</option> <option value=PCIS>PROTECTION AND CONTROL INFORMATION SYSTEM</option> <option value=PCSS>PROTECTION AND CONTROL SUPPORT SERVICES</option> <option value=PED>PROTECTION EXECUTION DOCUMENT</option> <option value=POP>PHASE OVER PHASE</option> <option value=PRA>PROJECT ROUTING AND APPROVAL</option> <option value=PT>POTENTIAL TRANSFORMER</option> <option value=RIM>RELAY INSTRUMENTATION AND METERING</option> <option value=RMS>ROOT MEAN SQUARE</option> <option value=RPA>R(TU) POINT ASSIGNMENT</option> <option value=RTU>REMOTE TERMINAL UNIT</option> <option value=S/N>SERIAL NUMBER</option> <option value=SA>SURGE ARRESTOR</option> <option value=SCADA>SUPERVISORY CONTROL AND DATA ACQUISITION</option> <option value=SESS>STATION ENGINEERING SUPPORT SERVICES</option> <option value=SOW>SCOPE OF WORK</option> <option value=SW>SWITCH</option> <option value=TCR>TRANSMISSION CONSTRUCTION REPRESENTATIVE</option> <option value=V>VOLT</option> <option value=VCB>VACUUM CIRCUIT BREAKER</option> <option value=WD>WIRING DIAGRAM</option> <option value=XF>TRANSFORMER</option> </select> </form><br> <input value="Click for ABBV" onclick="findABB()" type="button"> </br></br> <input type="text" name="myresultbox2" id="resultbox2" style="width:200px; height:75px;"> </fieldset><br> </body> </html> So in summary everything is working just want to make the result in the result box be able to be clinked to a specific link assigned. Thank you in advance. Hello all, I am new to these forms, and new to Javascript as well. I have gone through some lessons, and have been trying to write a simple script on my own. Here is what I am trying to do: I am calculating a volume, and want to display the result of that calculation. I then want to take the result and multiply it by 2 and display that as well. Here is what I have so far: Code: function volume (l, w, h) { return l * w * h; } console.log("Volume = " + volume (2, 2, 2)); So far so good... but I cant figure out how to then take that result that was displayed in the console and save it as a variable (if that would be the correct way to do it) so that I can modify the result by 2. I have tried several things with no luck. How can I save the result of a function or pass it to another function? Thanks in advance! Finally got my favorite system to work but there is 1 little detail left... When an item is in the favorites, the php file echoes: "Already Favorited!" how can I get that response? I have no experience with js whatsoever.. first time I used it. (obvious since I use code that i found on the tubes and modded it) This is my code: PHP Code: /* ---------------------------- */ /* XMLHTTPRequest Enable */ /* ---------------------------- */ function createObject() { var request_type; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ request_type = new ActiveXObject("Microsoft.XMLHTTP"); }else{ request_type = new XMLHttpRequest(); } return request_type; } var http = createObject(); var nocache = 0; function insert() { // Optional: Show a waiting message in the layer with ID login_response document.getElementById('insert_response').innerHTML = "Adding..." // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding. var user_id= encodeURI(document.getElementById('user_id').value); var item_id = encodeURI(document.getElementById('item_id').value); var cat_id = encodeURI(document.getElementById('cat_id').value); // Set te random number to add to URL request nocache = Math.floor(Math.random()); // Pass the login variables like URL variable http.open('get', 'http://animekyun.com/scripts/favorite.php?user_id='+user_id+'&item_id=' +item_id+'&cat_id=' +cat_id); http.onreadystatechange = insertReply; http.send(null); } function insertReply() { if(http.readyState == 4){ var response = http.responseText; document.getElementById('insert_response').innerHTML = 'Favorited'+response; } } Apparently this http.responseText is not working propperly since it's not returning anything Good day to you all, I'm working on a form which would display the result in the same div that the form is. Here is my code so far: PHP Code: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <textarea name="html"></textarea><br /> <input type="submit" onclick="load('<?php echo $_SERVER['PHP_SELF']; ?>','page');"/><br /> </form> Preview:<br /> <?php if(isset($_POST['html'])) echo stripslashes($_POST['html']); ?> <script type="text/javascript"> function ahah(url, target) { document.getElementById(target).innerHTML = ' Fetching data...'; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req != undefined) { req.onreadystatechange = function() {ahahDone(url, target);}; req.open("GET", url, true); req.send(""); } } function ahahDone(url, target) { if (req.readyState == 4) { // only if req is "loaded" if (req.status == 200) { // only if "OK" document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText; } } } function load(name, div) { ahah(name,div); return false; } </script> My problem is when I click on the button , the text in my text area don't show. Can somebody help me. Thanks! Hey Forum, I have this little script working great when all if's are seperated. what i need is to have the script read if one of these fields has a value then result=true. as you see the script now i have this seperated in many different if's for all three text fields. I need to put all text fields like they were one, thanks Code: function ValidateLink(Form) { var result = true; if (formMyLocations.cellAddress.value.length == 0) { alert('Cell address is empty on the locations page'); result = false; } if (formMyLocations.homeAddress.value.length == 0) { alert('Home address is empty on the locations page'); result = false; } if (formMyLocations.carAddress.value.length == 0) { alert('Car address is empty on the locations page'); result = false; } return result; } Can any one help me out please, i have two forms result and i need a function to sum and display the two forms result into one <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> function sum() { var one = parseFloat(document.myform.cost.value) var two = parseFloat(document.myform.insurance.value) var prod = one * two document.myform.amount.value=custRound(prod,2); } function custRound(x,places) { return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) } var Cost, GST, PST, Grand_Total; function tally() { Cost = 0; if (document.orderform.Item1.checked) { Cost = Cost + 26.15; } if (document.orderform.Item2.checked) { Cost = Cost + 26.10; } if (document.orderform.Item3.checked) { Cost = Cost + 26; } if (document.orderform.Item4.checked) { Cost = Cost + 26; } if (document.orderform.Item5.checked) { Cost = Cost + 26.44; } if (document.orderform.Item6.checked) { Cost = Cost + 26.01; } if (document.orderform.Item7.checked) { Cost = Cost + 26; } if (document.orderform.Item8.checked) { Cost = Cost + 26; } if (document.orderform.Item9.checked) { Cost = Cost + 25; } GST = (Cost * 0.07); PST = (Cost * 0.07); Cost = dollar(Cost); GST = dollar(GST); PST = dollar(PST); Grand_Total = parseFloat(Cost) + parseFloat(GST) + parseFloat(PST) ; Grand_Total = dollar(Grand_Total); document.orderform.Total.value = "$" + Cost; document.orderform.GST.value = "$" + GST; document.orderform.PST.value = "$" + PST; document.orderform.GrandTotal.value = "$" + Grand_Total; } function dollar (amount) { amount = parseInt(amount * 100); amount = parseFloat(amount/100); if (((amount) == Math.floor(amount)) && ((amount - Math.floor (amount)) == 0)) { amount = amount + ".00" return amount; } if ( ((amount * 10) - Math.floor(amount * 10)) == 0) { amount = amount + "0"; return amount; } if ( ((amount * 100) - Math.floor(amount * 100)) == 0) { amount = amount; return amount; } return amount; } </SCRIPT> </HEAD> <BODY> <H1 ALIGN = CENTER> in</H1> <H2 ALIGN = CENTER> PLEASE GET A QUOTE</H2> <FORM NAME="myform"> <P><B>VALUE OF Vehicle:</B> <input type="text" name="cost" onClick="sum()"> <P><B>Type of Insurance</B> <select name="insurance"> <option value="1.175" selected>Comprehensive</option> <option value="1.00">Third party only </option> <option value="0.75">Third party and thift</option> </select> <BR><input type="button" value="Get Quote" onClick="sum()" name="button"> <P>YOUR QUOTE </P> <input type="text" onClick="sum()" name="amount"> </FORM> </CENTER> <form method="post" name="orderform" action="mailto:ioduwa@yahoo.com" enctype="text/plain""> <table border="0"> <tr><td colspan="4"> <p><input type="checkbox" name="Item1" value="Item1_chosen" onclick="tally()"> Item One <p><input type="checkbox" name="Item2" value="Item2_chosen" onclick="tally()"> Item Two <p><input type="checkbox" name="Item3" value="Item3_chosen" onclick="tally()"> Item Three <p><input type="checkbox" name="Item4" value="Item4_chosen" onclick="tally()"> Item Four <p><input type="checkbox" name="Item5" value="Item5_chosen" onclick="tally()"> Item Five <p><input type="checkbox" name="Item6" value="Item6_chosen" onclick="tally()"> Item Six <p><input type="checkbox" name="Item7" value="Item7_chosen" onclick="tally()"> Item Seven <p><input type="checkbox" name="Item8" value="Item8_chosen" onclick="tally()"> Item Eight <p><input type="checkbox" name="Item9" value="Item9_chosen" onclick="tally()"> Item Nine </td></tr> <tr> <td> Total <input type="text" name="Total" value="$0" size="7"></td> <td> PST (7%) <input type="text" name="PST" value="$0" size="6"></td> <td colspan="2"> GST (7%) <input type="text" name="GST" value="$0" size="6"></td> </tr> <tr> <td> Grand Total <input type="text" name="GrandTotal" value="$0" size="8"></td> </tr> <tr> <td>Company Name:</td> <td colspan="3"><input type="Text" name="Company" size="35" maxlength="40"></td> </tr> <tr> <td>Contact Name:</td> <td colspan="3">First <input type="Text" name="FirstName" size="15" maxlength="20"> Last <input type="Text" name="LastName" size="15" maxlength="20"></td> </tr> <tr> <td>Address</td> <td><input type="Text" name="Street" size="20" maxlength="40"></td> </tr> <tr> <td>City</td> <td><input type="Text" name="City" size="20" maxlength="20"> </td> <td>Province/State:</td> <td><input type="Text" name="Province" size="20" maxlength="40"></td> </tr> <tr> <td>Country:</td> <td><input type="Text" name="Country" size="20" maxlength="20"></td> <td>Code:</td> <td><input type="Text" name="Code" size="9" maxlength="10"></td> </tr> <tr> <td>Phone:</td> <td><input type="Text" name="Area" size="3" maxlength="5"> <input type="Text" name="Phone" size="8" maxlength="10"></td> <td>Fax:</td> <td><input type="Text" name="AreaFax" size="3" maxlength="5"> <input type="Text" name="Fax" size="8" maxlength="10"></td> </tr> <tr> <td>Email Address:</td> <td colspan=2><input type="Text" name="Email" size="30" maxlength="30"></td> </tr> <tr><td colspan="4" height="3"><hr></td></tr> <tr><td colspan="2" align="center"><input type="Submit" value="Send Order"></td> <td colspan="2" align="center"><input type="RESET" value="Reset Order"></td></tr> </table> </form> </html> When I hit the submit button, the result are display on a new page. how do I force it to stay on the same page, here's my code. Code: <HTML> <HEAD> <TITLE>Test Input</TITLE> <script type="text/javascript"> function addtext() { var newtext = document.myform.inputbox.value; document.writeln(newtext); } </script> </HEAD> <BODY> <FORM NAME="myform">Enter something in the box: <BR> <INPUT TYPE="text" NAME="inputbox" VALUE=""> <INPUT TYPE="button" NAME="button" Value="Check" onClick="addtext()"> </FORM> </BODY> </HTML> any comments or suggestions would be greatly appreciated. Can anyonle pls explain me why the return function is not returning the result as intended? I appreciate you help OUTPUT ====== Student : Doe,John eMail : johndoe@gmail.com Course ID : COIN-070B.01 -------------------------------- function task() { var title = ["Assignment1", "Assignment2", "Assignment3", "Assignment4", "Assignment5", "Mid Term", "Finals"]; var points = [30, 30, 28, 27, 29, 41, 45]; for (var i = 0; i < points.length; i++) { titlePoints += title[i] + (" : " + points[i] + "\n"); } return titlePoints; } Code: <head> <title>Variable - Examples 1</title> <script type="text/javascript"> function Student(firstName, lastName, email,courseID){ this.firstName = firstName; this.lastName = lastName; this.email = email; this.courseID = courseID; this.assignments = task; } Student.prototype = { constructor : Student, toString : studentInfo }; function task(){ var title = ["Assignment1","Assignment2","Assignment3","Assignment4","Assignment5","Mid Term", "Finals"] var points = [30, 30, 28, 27, 29,41,45]; var titlePoints = ""; for (var i=0; i < points.length; i++){ titlePoints += title[i] + " : " + points[i] + "\n"; } return titlePoints; } function studentInfo(){ return "Student : " + this.lastName + "," + this.firstName + "<br>"+ "eMail : " + this.email + "<br>" + "Course ID : " + this.courseID + "<br>" + "--------------------------------" + "<br>" + this.assignments; } var student = new Student("John", "Doe", "johndoe@gmail.com","COIN-070B.01"); </script> </head> <body> <script type="text/javascript"> document.writeln(student.toString()); </script> </body> </html> I wrote quiz using HTML and JavaScrip. Score is accumulated in a variable called myScore. Now I want to email the result of myScore to an email address. How do I go about doing this? I don't want to use the mailto: command since that require that user actually press the send command to send the email. I want this done automatically after user finishes the quiz. Please explain all replied in details since I am new to JavaScript and still learning. Hey guys, I've been learning Javascript for a few days using code academy. I've come across this issue, and I'm not sure what exactly I'm doing wrong. Any help would be great. // Check if the user is ready to play! confirm("I am ready to play!"); var age = prompt("What's your age?"); if (age < 13) { console.log("I take no responsiblity, but you are allowed to play") } else { console.log("Have fun!") } console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'") console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'") var userAnswer = prompt("Do you want to race Bieber on stage?"); if userAnswer === "yes" { console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!"); } else { console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'"); } |