Practice Problems: These problems are intended to clarify some of the basic concepts related to access to some of the form controls. In the process you should enter the problems in the computer and run them to check for their proper functioning. 1: Working with Radio Buttons <HTML> <HEAD> <TITLE>Extracting Highlighted Radio Button</TITLE> <SCRIPT LANGUAGE="JavaScript">. </SCRIPT> </HEAD> <BODY> <HR> <FORM action = ASPtest.asp method = post > <B>Select the criteria for which you want the points in COMS463:</B><P> <INPUT TYPE="radio" NAME="coms463" VALUE="Project: 40" CHECKED>Project <INPUT TYPE="radio" NAME="coms463" VALUE="Assignment : 10" >Assignment <INPUT TYPE="radio" NAME="coms463" VALUE="Midterm : 25" >Midterm <INPUT TYPE="radio" NAME="coms463" VALUE="Final : 25" >Final<P> <INPUT TYPE="button" NAME="Viewer" VALUE="View 463 Points..." onclick="showpoints63()"> </FORM> <FORM action = ASPtest.asp method = post > <HR><BR> <B> Select the criteria for which you want the points in COMS462:</B><P> <INPUT TYPE="radio" NAME="coms462" VALUE="Programming : 20" >Programming <INPUT TYPE="radio" NAME="coms462" VALUE="Lab Works : 25" CHECKED >Lab Works <INPUT TYPE="radio" NAME="coms462" VALUE="Quiz : 15" >Quiz <INPUT TYPE="radio" NAME="coms462" VALUE="Exam1: 20" >Exam1 <INPUT TYPE="radio" NAME="coms462" VALUE="Final : 20" >Final<P> <INPUT TYPE="button" NAME="Viewer" VALUE="View 462 Points..." onclick="showpoints62()"> </FORM> <HR> </BODY> </HTML> HTML Question: a. Draw the screen output of the above HTML code. JavaScript Questions: a. Write a JavaScript statement to print out on an alert window the number of radio buttons included in the form that has the group name i. coms463 ii. coms462 b. Write a JavaScript statement to print out as an alert box the value of the first Radio button (whether or not selected) in the first form. (Note that JavaScript uses index 0 for the first button) c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form. d. Write JavaScript code segment to assign the value of the selected radio button in the first form to a variable named allocatedpoint1. e. Write a JavaScript statement to print the value of allocatedpoint1 on the screen.
f. Write JavaScript code segment to assign the value of the selected radio button in the second form to a variable named allocatedpoint2. g. Write a JavaScript statement to print the value of allocatedpoint2 on the screen. h. Write JavaScript function that will print on the screen an alert box the sentence In COMS463 the allocated point for followed by the value of the selected radio button in the first form. i. Write JavaScript function that will print on the screen an alert box the sentence In COMS462 the allocated point for followed by the value of the selected radio button in the second form. ASP Questions: a. Write ASP statement to print on the screen the value of the radio button selected when the first form is b. Write ASP statement to print on the screen the value of the radio button selected when the second form is c. Write ASP code to store value of the selected radio in one cookie called pointfortask1 when the first form is d. Write ASP code to store value of the selected radio in one cookie called pointfortask2 when the second form is e. Write ASP code so that the cookie pointfortask1 remain stored for 7 days. f. Write ASP code so that the cookie pointfortask1 gets deleted. g. Write ASP code to display the value of the selected radio in a text box for any of the form submitted. (Assume that at least one radio is selected.) h. Write ASP code to display the value of the selected radio in a text box for any of the form submitted. However, the text box should not bee seen on the screen. (Assume that at least one radio is selected.) g. Write ASP code to check the radio selections if the user has submitted the second form with Quiz selected. If yes, store 15 in a session variable called Quiz. h. Write an ASP statement to delete the session variable Quiz. 2: Working with Selection for single choices Change the HTML code in practice problem 1 so that the user is able to make a selection of the choices from a list instead of radio buttons and get the same functionality. Complete all the exercises listed in practice problem 1.
3: Working with Checkboxes <html> <head> <title>extracting Highlighted checkboxes</title> <script LANGUAGE="JavaScript">. </script> </head> <body> <form action="asptest.asp" method="post"> <b><p>select the criteria for which you want the points in COMS463:</b></p> <p><input TYPE="checkbox" NAME="coms463" VALUE="Project: 40" CHECKED>Project <input TYPE="checkbox" NAME="coms463" VALUE="Assignment : 10">Assignment <input TYPE="checkbox" NAME="coms463" VALUE="Midterm : 25">Midterm <input TYPE="checkbox" NAME="coms463" VALUE="Final : 25">Final</p> <p><input TYPE="submit" NAME="Viewer" VALUE="View 463 Points..." onclick="return ShowPoints63()"> </p> </form> <form action="asptest.asp" method="post"> <p><br> <b>select the criteria for which you want the points in COMS462:</b></p> <p><input TYPE="checkbox" NAME="coms462" VALUE="Programming : 20">Programming <input TYPE="checkbox" NAME="coms462" VALUE="Lab Works : 25" CHECKED>Lab Works <input TYPE="checkbox" NAME="coms462" VALUE="Quiz : 15">Quiz <input TYPE="checkbox" NAME="coms462" VALUE="Exam1: 20">Exam1 <input TYPE="checkbox" NAME="coms462" VALUE="Final : 20">Final</p> <p><input TYPE="submit" NAME="Viewer" VALUE="View 462 Points..." onclick="return ShowPoints62()"> </p> </form> </body> </html> HTML Question: a. Draw the screen output of the above HTML code. JavaScript Questions: a. Write a JavaScript statement to print out on an alert window the number of checkboxes included in the form that has the group name i. coms463 ii. coms462 b. Write a JavaScript statement to print out as an alert box the value of the first checkbox (whether or not selected) in the first form. (Note that JavaScript uses index 0 for the first Checkbox) c. Write a JavaScript statement to print out as an alert box the value of the third Checkbox (whether or not selected) in the second form. d. Write JavaScript code segment to assign the value of the selected Checkbox in the first form to a variable named allocatedpoint1.
e. Write a JavaScript statement to print the value of allocatedpoint1 on the screen. f. Write JavaScript code segment to assign the value of the selected checkboxes in the second form to a variable named allocatedpoint2. g. Write a JavaScript statement to print the value of allocationpoint2 on the screen. h. Write JavaScript function that will print on the screen the total count of checkboxes selected in the first form. i. Write JavaScript function that will print on the screen values for each of the selected check boxes, one after the other in alert boxes, with the sentence In COMS463 the allocated point for followed by the values of the selected check boxes in the first form. j. Write JavaScript function that will print on the screen values for each of the selected check boxes, one after the other the alert boxes, with the sentence In COMS462 the allocated point for followed by the values of the selected check boxes in the second form. k. Write JavaScript code segment that will print on the screen the total count of the selected check boxes in the first and the second form. ASP Questions: a. Write ASP statement to print on the screen the count of the check boxes selected when the first form is submitted. (Assume that at least one checkbox is selected.) b. Write ASP statement to print on the screen in different lines the values of the check boxes selected when the first form is submitted. (Assume that at least one checkbox is selected.) c. Write ASP statement to print on the screen in different lines the values of the check boxes selected when the second form is submitted. (Assume that at least one checkbox is selected.) d. Write ASP code to store value of all selected check boxes in one cookie called pointfortask1 when the first form is submitted. (Assume that at least one check box is selected.) e. Write ASP code to store value of all selected check boxes in one cookie called pointfortask2 when the second form is submitted. (Assume that at least one check box is selected.) f. Write ASP code so that the cookie pointfortask1 remain stored for 7 days. g. Write ASP code so that the cookie pointfortask1 gets deleted. h. Write ASP code to display the value of the selected check boxes each in one text box when the first form is submitted. (Assume that at least one check box is selected. Note that the number of text boxes will equal to the number of check boxes selected.) i. Write ASP code to display the value of the selected check boxes each in one text box when the second form is submitted. (Assume that at least one check box is selected. Note that the number of text boxes will equal to the number of check boxes selected.) j. Write ASP code to display the value of the selected check boxes each in one text box as in i and j above. However, the text box should not bee seen on the screen. (Assume that at least one radio is selected.) m. Write ASP code to identify if the user has submitted the second form with Quiz selected. If yes, store 15 in a session variable called Quiz. (Assume that at least two of the check boxes is selected.)
h. Write an ASP statement to delete the session variable Quiz. i. Write ASP code to print on the screen the value of the last checkbox selected when the first form is j. Write ASP code to print on the screen the value of the second checkbox selected when the first form is k. Write ASP code to print on the screen the value of the 3rd checkbox selected when the second form is 4: Working with Selection for multiple choices Change the HTML code in practice problem 2 so that the user is able to make a selection of the choices from a list (multiple at a time) instead of radio buttons and get the same functionality. Complete all the exercises listed in practice problem 2. 5: Some More a. Write HTML code to display three text boxes on a screen. In the first text box you may enter a number 1, 2 or 3 followed by space(s) and then any sentence. After clicking on the button the sentence (without the numbers) should be displayed in the appropriate text box (1, 2 or 3) identified by the leading number entered in the first text box. If you identify that the leading number in the given range is missing in the first text box, then an error message is given to follow the specification. i. Write a JavaScript function to achieve the above functionality. ii. Write ASP code to achieve the above functionality. Note: Selected solutions of only few will be posted on the web page on Monday or Tuesday.