@@ -69,26 +69,27 @@ <h2>Enter Credentials Before Taking the Quiz</h2>
6969
7070 < script >
7171 function submitCredentials ( ) {
72- let name = document . getElementById ( "name" ) . value ;
73- let deptYear = document . getElementById ( "deptYear" ) . value ;
74- let gender = document . getElementById ( "gender" ) . value ;
72+ let name = document . getElementById ( "name" ) . value ;
73+ let deptYear = document . getElementById ( "deptYear" ) . value ;
74+ let gender = document . getElementById ( "gender" ) . value ;
7575
76- if ( ! name || ! deptYear || ! gender ) {
77- alert ( "Please fill in all details." ) ;
78- return ;
79- }
76+ if ( ! name || ! deptYear || ! gender ) {
77+ alert ( "Please fill in all details." ) ;
78+ return ;
79+ }
80+
81+ fetch ( "https://script.google.com/macros/s/YOUR_GOOGLE_SCRIPT_URL/exec" , {
82+ method : "POST" ,
83+ headers : { "Content-Type" : "application/json" } ,
84+ body : JSON . stringify ( { name, deptYear, gender } )
85+ } )
86+ . then ( response => response . text ( ) )
87+ . then ( ( ) => {
88+ window . location . href = "quiz.html" ; // Redirect to quiz.html after successful submission
89+ } )
90+ . catch ( error => console . error ( "Error:" , error ) ) ;
91+ }
8092
81- fetch ( "https://script.google.com/macros/s/https://script.google.com/macros/s/AKfycbzj-Qgc0tYgmjiaYO5oZvzhcCR0LiIPxCGhi-sQbEnxjvyoy8WJojJhtEDnDoZJwfDKzg/exec/exec" , {
82- method : "POST" ,
83- headers : { "Content-Type" : "application/json" } ,
84- body : JSON . stringify ( { name, deptYear, gender } )
85- } )
86- . then ( response => response . text ( ) )
87- . then ( ( ) => {
88- window . location . href = 'quiz1.html' ;
89- } )
90- . catch ( error => console . error ( "Error:" , error ) ) ;
91- }
9293 </ script >
9394</ body >
9495</ html >
0 commit comments