I posted a questoin about this last week and have been working with the problem since. firstly, i'm new to javascript but i've been pounding it into my head for days now and it's starting to look familiar but i'm still a way from really getting ok at writing it. so here's my problem (this is for my job.. btw so i'm kind of pressed to get it done soon)
i have a form with 2 sections. section 1 is several drop down selections and section 2 is a set of yes/no radio buttons. i want to pass the textual values into a function that will step through each value (ex. Q1=Preschool, Q2=Literate, ... Q10=yes, Q11=no, etc). there are 18 questions. i have managed to build the form and get a little functionality into it because when i click the 'Process' button, i can see all of the variable names and their values in the address bar so i know it took the values and sent them (to nowhere at the moment). i have an array that contains 7 variables to gather these values once they're converted to numbers.. then the array is to be sorted and displayed in reverse descending order (bigger number to smaller number).
what i need to do now is have those values stepped through and evaluated…
example in pseudcode:
-----
devices new Array(DV1, DV2, DV3, DV4, DV5, DV6, DV7);
function evalQ(whatgoeshere?) {
if (Q1=Preschool) {
add 1 to DV1;
add 1 to DV2;
add 1 to DV6; }
else if (Q1=Elementary) {
add 1 to DV3;
add 1 to DV4;
add 1 to DV1; }
else if (Q1=TeenAdult) {
add 1 to DV2;
add 1 to DV4;
add 1 to DV5;
add 1 to DV6; }
}
/* the function should iterate through each of the 18 questions, evaluate which value was passed to the Q* variable, and add the point to the correct array variables. next... */
sort devices /*list in descending order*/
-------
i'll post the code i have so far (it's not much and wrong for sure.)
i could use some help with this as i have no formal training in javascript. i took an intro to programming course so i'm familiar with the concepts of looping and functions (sorta) and so on.
thanks for the help!
Aaron
i have a form with 2 sections. section 1 is several drop down selections and section 2 is a set of yes/no radio buttons. i want to pass the textual values into a function that will step through each value (ex. Q1=Preschool, Q2=Literate, ... Q10=yes, Q11=no, etc). there are 18 questions. i have managed to build the form and get a little functionality into it because when i click the 'Process' button, i can see all of the variable names and their values in the address bar so i know it took the values and sent them (to nowhere at the moment). i have an array that contains 7 variables to gather these values once they're converted to numbers.. then the array is to be sorted and displayed in reverse descending order (bigger number to smaller number).
what i need to do now is have those values stepped through and evaluated…
example in pseudcode:
-----
devices new Array(DV1, DV2, DV3, DV4, DV5, DV6, DV7);
function evalQ(whatgoeshere?) {
if (Q1=Preschool) {
add 1 to DV1;
add 1 to DV2;
add 1 to DV6; }
else if (Q1=Elementary) {
add 1 to DV3;
add 1 to DV4;
add 1 to DV1; }
else if (Q1=TeenAdult) {
add 1 to DV2;
add 1 to DV4;
add 1 to DV5;
add 1 to DV6; }
}
/* the function should iterate through each of the 18 questions, evaluate which value was passed to the Q* variable, and add the point to the correct array variables. next... */
sort devices /*list in descending order*/
-------
i'll post the code i have so far (it's not much and wrong for sure.)
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"> <html> <head> <title>Device Evaluation Form</title> <script language="Javascript"> devices new Array(DV4, MT4, WRT, DMO, TXL, HND, PLM); inputs = document.form['Eval'].getElementsByTagName('input'); function addPoints(device) { if (device == "Emergent") { for(var i=0; i<=inputs.length; i++) { DV4 = + DV4[i];} } } document.write(DV4); </script> </head> <body> <form name="Eval"> ---Section 1---------<br><br> Age? <select name="Q1"><br> <option value="Preschool">Preschool</option> <option value="Elementary">Elementary</option> <option value="TeenAdult">Teen/Adult</option> </select> <br> Literacy? <select name="Q2"> <option value="Emergent">Emergent</option> <option value="PreLiterate">PreLiterate</option> <option value="Literate">Literate</option> </select> <br> Cognition? <select name="Q3"> <option value="NoneMild">None/Mild</option> <option value="Moderate">Moderate</option> <option value="Severe">Severe</option> </select> <br> Physical State? <select name="Q4"> <option value="PhysDegenerate">Degenerate</option> <option value="PhysStatic">Static</option> <option value="PhysImproving">Improving</option> </select> <br> Dexterity? <select name="Q5"> <option value="Finemotor">Fine Motor</option> <option value="Impaired">Impaired</option> <option value="SevImpaired">Severely Impaired</option> </select> <br> Mental State? <select name="Q6"> <option value="MentlDegen">Degenerative</option> <option value="MentlStatic">Static</option> <option value="MentlImproving">Improving</option> </select> <br> Support? <select name="Q7"> <option value="Self">Self</option> <option value="SpsePrnt">Spouse/Parent</option> <option value="GoodTeam">Good Team</option> </select> <br> Payor? <select name="Q8"> <option value="PrvtIns">Private Ins.</option> <option value="Govt">Government</option> <option value="School">School</option> </select> <br> <br><br> ---Section 2---------<br><br> 3rd Party Software? <input type="radio" value="yes" name="Q9">Yes <input type="radio" value="no" name="Q9">No<br> <br> Email Address? <input type="radio" value="yes"name="Q10">Yes <input type="radio" value="no"name="Q10">No<br> <br> Internet Access? <input type="radio" value="yes"name="Q11">Yes <input type="radio" value="yes"name="Q11">No<br> <br> Computer Access? <input type="radio" value="yes"name="Q12">Yes <input type="radio" value="yes"name="Q12">No<br> <br> Phone Access? <input type="radio" value="yes"name="Q13">Yes <input type="radio" value="yes"name="Q13">No<br> <br> User Programming? <input type="radio" value="yes"name="Q14">Yes <input type="radio" value="yes"name="Q14">No<br> <br> ECU? <input type="radio" value="yes"name="Q15">Yes <input type="radio" value="yes"name="Q15">No<br> <br> Simplicity? <input type="radio" value="yes"name="Q16">Yes <input type="radio" value="yes"name="Q16">No<br> <br> Light to Carry? <input type="radio" value="yes"name="Q17">Yes <input type="radio" value="yes"name="Q17">No<br> <br> Vision Problems? <input type="radio" value="yes"name="Q18">Yes <input type="radio" value="yes"name="Q18">No<br> <br> <input type="submit" name="Process" value="Process" onclick="return addPoints(this); return false;"> </form> </body> </html>
i could use some help with this as i have no formal training in javascript. i took an intro to programming course so i'm familiar with the concepts of looping and functions (sorta) and so on.
thanks for the help!
Aaron
Comment