JavaScript - Hello, I'm Hoping Someone Here Can Help Me With This, I'd Be Greatful
Hello
I work for a small company and alot of the people we deal with are old and not good with computers. I'm trying to make a dropdown combo-box that will help them find what they need. I've gotten the boxes working, but I need the results to then go into a search box. Any help would be greatly appreciated. <html> <!-- Created on: 3/24/2011 --> <head> <script type="text/javascript"> var categories = []; categories["startList"] = ["Activa","Bell Horn","Diabetic Crew","Futuro","Jobst","Sensifoot","TruSock"] categories["Activa"] = ["Male","Female"] categories["Bell Horn"] = ["Male","Female"] categories["Diabetic Crew"] = ["Male","Female"] categories["Futuro"] = ["Male","Female"] categories["Jobst"] = ["Male","Female"] categories["Sensifoot"] = ["Male","Female"] categories["TruSock"] = ["Male","Female"] categories["Male"] = ["Ankle High","Crew","Knee High"]; categories["Female"] = ["Ankle High","Crew","Knee High"]; categories["Ankle High"] = ["8-15 mmHg","15-20 mmHg","20-30 mmHg","30-40 mmHg"]; categories["Crew"] = ["8-15 mmHg","15-20 mmHg","20-30 mmHg", "30-40 mmHg"]; categories["Knee High"] = ["8-15 mmHg", "15-20 mmHg", "20-30 mmHg", "30-40 mmHg"]; categories["8-15 mmHg"] = ["Casual","Dress"]; categories["15-20 mmHg"] = ["Casual","Dress"]; categories["20-30 mmHg"] = ["Casual","Dress"]; categories["30-40 mmHg"] = ["Casual","Dress"]; var nLists = 5; // number of select lists in the set function fillSelect(currCat,currList){ var step = Number(currList.name.replace(/\D/g,"")); for (i=step; i<nLists+1; i++) { document.forms['tripleplay']['List'+i].length = 1; document.forms['tripleplay']['List'+i].selectedIndex = 0; } var nCat = categories[currCat]; for (each in nCat) { var nOption = document.createElement('option'); var nData = document.createTextNode(nCat[each]); nOption.setAttribute('value',nCat[each]); nOption.appendChild(nData); currList.appendChild(nOption); } } function getValue(L4, L3, L2, L1, L5) { alert("Your selection was:- \n" + L2 + "\n" + L1 + "\n" + L3 + "\n" + L4 + "\n" + L5); } function init() { fillSelect('startList',document.forms['tripleplay']['List1']) } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> </head> <body> <table border="0" summary=""> <tr> <td><BR> <b>Brand: </b><BR> <b>Gender: </b><BR> <b>Cut: </b><BR> <b>Compression: </b><BR> <b>Style: </b> </td> <td><BR> <BR> <form name="tripleplay" action=""> </b><select name='List1' onchange="fillSelect(this.value,this.form['List2'])"> <option selected>Make a selection</option> </select> <BR> </b><select name='List2' onchange="fillSelect(this.value,this.form['List3'])"> <option selected>Make a selection</option> </select> <BR> <select name='List3' onchange="fillSelect(this.value,this.form['List4'])"> <option selected>Make a selection</option> </select> <BR> <select name='List4' onchange="fillSelect(this.value,this.form['List5'])"> <option selected>Make a selection</option> </select> <BR> <select name='List5' onchange="getValue(this.value, this.form['List1'].value, this.form['List1'].value)"> <option selected >Make a selection</option> </select> </form> </td> </tr> </table> <input type="text" name="testField" maxlength="50" size="30" value="This is where I want the result to go."> </body> </html> Similar TutorialsHere is my assignment http://www.sci.brooklyn.cuny.edu/~ci...omework3B.html Here is my html file, magic.html: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <SCRIPT SRC="Project3B.js"> </SCRIPT> </head> <form name="sqaure"> <table border="1"> <tr><td><input type="text" id="a00" size="4"/></td> <td><input type="text" id="a01" size="4"/></td> <td><input type="text" id="a02" size="4"/></td></tr> <tr><td><input type="text" id="a10" size="4"/></td> <td><input type="text" id="a11" size="4"/></td> <td><input type="text" id="a12" size="4"/></td></tr> <tr><td><input type="text" id="a20" size="4"/></td> <td><input type="text" id="a21" size="4"/></td> <td><input type="text" id="a22" size="4"/></td></tr> </table> <button onclick="compute(sqaure);">check</button> </form> </div> </body> </html> Here is my .js file also properly named: Code: <!-- hide script from old browsers function compute ( f ) { var isDifferent=true; var addsToSame=true; if( (distinct ( create_square (f) ) ) == false) { isDifferent=false } if( (same_sum( create_square (f) ) ) == false) { addToSame=fa;se; } } function create_square ( f ) { Array = new Array(2); Array [0] = new Array(2); Array [0][0] = a00.value; Array [0][1] = a01.value; Array [0][2] = a02.value; Array [1] = new Array(2); Array [1][0] = a10.value; Array [1][1] = a11.value; Array [1][2] = a12.value; Array [2] = new Array(2); Array [2][0] = a20.value; Array [2][1] = a21.value; Array [2][2] = a22.value; return Array; } function distinct(a) { var isDistinct=true; var h=0; var i=0; var j=0; for (h=0;h<3;h++) { for (i=0;i<3;i++) { for(j=0;j<3;j++) { if(isDistinct==true) { if(a[h][j]==array[i][j]) { isDistinct=false; } } } } } if(isDistinct=false) { alert ("Not all numbers are distinct") return isDistinct; } } function same_sum(a) { var sum = 0; var i = 0; var TorF = true; for (i=0;i<3;i++) { if (TorF == True) { if( var sum != 0) { if( sum != row_sum(a, i) ) { TorF = false } } else { sum = row_sum( a, i) } } } for (=0;i<3;i++) { if (TorF == True) { if(sum != col_sum(a, i) ) { TorF = false } } } if(TorF == False) { alert ("Not all rows/columns add to same number") return TorF; } } function row_sum(a, r) { var total=a[r][0]+a[r][1]+a[r][2]; return total } function col_sum(array, i) { var total=a[0][c]+a[1][c]+a[2][c]; return total } // end hiding script from old browsers --> Sorry if it looks really odd...i am not entirely sure on javascript, I sorta....partially writing the code based on my experience with C++, and I have heard that would punish me ofcourse...but...the program seemed easy enough. Anyway help would be appreciated...if someone could recommend me a program or something I could use for debugging for javascript that would also help. PS....the title is supposed to be "I did a lot of code kinda so I am hoping someone is willing to help me lol"...its late >.> I am trying to do a title case project and can't figure out where I went wrong. Any help would be appreciated. <!DOCTYPE html> <html lang="en"> <head> <title>Title Case</title> <meta charset="utf-8"> <script type="text/javascript"> function titleCase() { var word = document.forms[0].string.value.split(" "); var cword = ""; for (var i = 0; i < word.length; i++) { cword = cword + word[i].substr(0, 1).toUpperCase() + word[i].substr(1).toLowerCase() + ((i < word.length - 1) ? " " : ""); } return cword; } </script> </head> <body> <h1>Title Case</h1> <form action="" method="get"> <p><input type="text" name="string" /> <input type="button" value="Convert to Title Case" onclick="titleCase()" /></p> </form> </body> </html> |