<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
/**
new option(descript,value);
Option是select中的选择项,descript是页面中看到的描述,而value是这一项的值,比如
<option value="这里是value">这里是descript</option>
new option(); 一般用在动态生成选择项目
**/
var m_list=[[1,2,3,45,666,77]];
function change()
{
var e = document.myform.elements["jx"];
e.innerHTML = "";
with(e)//look here,with 用于简化代码;表示在with语句中的任何表达式的所属对象或者是类都由with后紧跟的变量所代表
{
options[0] = new Option("选择机型", "");//e元素下的options
var d = m_list[0];
var idx = 0;
for(var i in d)
{
if(d[i].length < 1){
continue;
}
var y = "--" +d[i] + "--";
options[idx++] = new Option(y, d[i]);
}
}
}
function showValue(sel){
if(sel){
with(sel){//
alert(value);//select元素的value,相当于document.getElementById('jx').value;
}
}
}
</script>
</HEAD>
<BODY>
<form name='myform'>
<select name="jx" onchange='javascript:showValue(this)'>------------</select>
</br>
<input type='button' value='Add Select Option' onclick='javascript:change();'>
</form>
</BODY>
</HTML>
分享到:
相关推荐
Back-End Interaction with Ajax and Node.js Data Validation Techniques Modern JavaScript Case Study: A Dynamic Gallery Using Third-Party JavaScript Appendix A: Debugging JavaScript Book Details ...
Back-End Interaction with Ajax and Node.js Chapter 9. Data Validation Techniques Chapter 10. Modern JavaScript Case Study: A Dynamic Gallery Chapter 11. Using Third-Party JavaScript Appendix A. ...
JavaScript with Promises
using JavaScript and p5.js and secondarily in creating visuals. The main focus is to teach you how to program so that you can choose to pursue whatever field that you would like with your newly ...
Beginning JavaScript with DOM Scripting and Ajax
Beginning Javascript with DOM Scripting and Ajax (From Novice to Professional) Javascript DOM和Ajax编程,从新手到专家!! 推荐!!!
Code from scratch and create computer graphics with JavaScript and the p5.js library Gain the necessary skills to move into your own creative projects Create graphics and interactive experiences ...
Beginning JavaScript with DOM Scripting and Ajax(2nd) 英文epub 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Beginning JavaScript with DOM Scripting and Ajax, 2nd Edition: This book will teach you about JavaScript and how to use it in a practical manner. After you read it, you’ll be able to Understand ...
Learn JavaScript with p5.js Coding for Visual Learners 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
Learn JavaScript with p5.js Coding for Visual Learners 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或...
Learning PHP, MySQL & JavaScript With jQuery, CSS & HTML5(5th) 英文epub 第5版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
Moodle 2.9+ JavaScript with AMD
Puzzle Game using JavaScript with Source Code
Multiplying Number Game using JavaScript with Source Code
Movie Searcher App in JavaScript with Source Code
Pixel Maker App using JavaScript with Source Code