change.js

来自「这是《JavaScript学习源代码》一书的源代码」· JavaScript 代码 · 共 19 行

JS
19
字号
// specify a LOAD event-handler
window.onload = init;

// specify a CHANGE event-handler
function init()
{               
  window.document.forms.f.s.onchange = show_selected; 
  //set inital values
  window.document.forms.f.s.options[1].selected=true;  
  window.document.forms.f.txt.value="";          
}                                               

// a function to react to the CHANGE event
function show_selected()
{    
  var num = window.document.forms.f.s.selectedIndex;
              
  window.document.forms.f.txt.value = window.document.forms.f.s.options[num].value;
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?