File tree Expand file tree Collapse file tree
user-input-with-forms/studio Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33< head >
44 < meta charset ="utf-8 ">
55 < script >
6- // TODO: create a handler
6+ function setSearchEngine ( ) {
7+ document . getElementById ( 'searchForm' ) . setAttribute ( "action" , actionsURL [ document . querySelector ( "input[name=engine]:checked" ) . value ] ) ;
8+ return ;
9+ } ;
710 window . addEventListener ( "load" , function ( ) {
8- // TODO: register the handler
11+ let button = document . getElementById ( "goButton" ) ;
12+ button . addEventListener ( "click" , setSearchEngine ) ;
913 } ) ;
14+ let actionsURL = {
15+ google : 'https://www.google.com/search' ,
16+ duckduckgo : 'https://duckduckgo.com/' ,
17+ bing : 'https://www.bing.com/search' ,
18+ ask : 'https://www.ask.com/web'
19+ } ;
20+ let searchForm = document . getElementById ( 'searchForm' ) ;
21+ searchForm . setAttribute ( "action" , ) ;
1022 </ script >
1123</ head >
1224
1325< body >
1426
1527 < form id ="searchForm ">
16- <!-- TODO: add form elements -->
28+ < label > name< input type ="text " name ="q "> </ label >
29+ < label > Google< input value ="google " type ="radio " name ="engine "> </ label >
30+ < label > DuckDuckGo< input value ="duckduckgo " type ="radio " name ="engine "> </ label >
31+ < label > Bing< input value ="bing " type ="radio " name ="engine "> </ label >
32+ < label > Ask< input value ="ask " type ="radio " name ="engine "> </ label >
33+ < button id ="goButton " value ="Go! "> Go!</ button >
1734 </ form >
1835
1936</ body >
You can’t perform that action at this time.
0 commit comments