


js manipulation of cross-frame three-level linkage select drop-down option example introduction_javascript skills
Use relevant knowledge of HTML, CSS and Javascript to write multi-window and multi-menu content linkage.
Examine students’ concepts of frame, browser objects, and form controls, JavaScript event triggering mechanism and programming,
and their mastery of using CSS to organize text display, so that students have a deeper understanding of DHTML understanding.
Experimental content [must do]
(1) Create a window containing three frames
(2) The first frame1 contains a select, and the content is each province in China
(3) The second frame 2 also contains a select, which contains prefecture-level cities in each province
(4) The third frame 3 is used to display an introduction to a certain prefecture and city.
(5) When a province is selected in the select of frame1, the select in frame2 will automatically change the available options to the cities in that province
(6) When a certain city is selected in the select of frame2 Finally, display the introduction of the city in frame3
(7) The introduction is required to be contained in div, aligned to the left, blue text, 20px, and the first line indented.
Menu linkage reference interface effect
Tips: There are many ways to implement this experiment (for example: css version, dom version, ajax version, prototype version) ), students only need to choose an implementation method.
Menu linkage test related data
Jiangsu
Nanjing Nanjing is the capital of Jiangsu Province and the ancient capital of six dynasties with rich historical relics and profound cultural heritage.
Taizhou Taizhou is a thousand-year-old county, where Chairman Hu was born and the hometown of Teacher Wang. It is famous for its mahjong, especially mahjong.
Suzhou "There is heaven above, and Suzhou and Hangzhou below." Suzhou is famous for its gardens. Famous gardens include "Humble Administrator's Garden", "Lion Grove", etc. It has outstanding people and literati.
Zhejiang
Hangzhou Hangzhou is the capital of Zhejiang Province, with beautiful scenery and a paradise on earth. It is said that "there is heaven above, and Suzhou and Hangzhou below".
Wenzhou Wenzhou is most famous for its businessmen. Almost everyone in Wenzhou is engaged in business. The Wenzhou real estate speculators who are hated by the whole country are the representatives!
Jiaxing The only understanding of Jiaxing is the historic conference held on Jiaxing South Lake.
Guangdong
Guangzhou Guangzhou is the capital of Guangdong Province, with a developed economy, but rampant crime!
Shenzhen Shenzhen is the first special economic zone in the country. It has a developed economy and almost all immigrants. Like Guangzhou, the public security is not good.
Zhuhai Zhuhai is one of the first coastal open cities in my country. The city is beautiful, a typical coastal city, and suitable for living.
I wrote a js code that doesn’t have too much of a shit flavor for all readers and lazy people to enjoy.
Code above:
1.frame_a.htm: Display the drop-down list of province
Frame A
2.frame_b.htm: Display all cities of a certain identity Drop-down list
Frame B
3.frame_c.htm: Display the description of the corresponding city description.
Frame C
4,index.htm: Global framework, master control page .
< script language="javascript" type="text/javascript">
var provinces = new Array();
provinces[0] = "Jiangsu";
provinces[1] = "Zhejiang";
provinces[2] = "Guangdong";
var cities = new Array();
cities[0] = new Array();
cities[0][0] = "Nanjing" ;
cities[0][1] = "Taizhou";
cities[0][2] = "Suzhou";
cities[1] = new Array();
cities[1 ][0] = "Hangzhou";
cities[1][1] = "Wenzhou";
cities[1][2] = "Jiaxing";
cities[2] = new Array( );
cities[2][0] = "Guangzhou";
cities[2][1] = "Shenzhen";
cities[2][2] = "Zhuhai";
var descriptions = new Array();
descriptions[0] = new Array();
descriptions[0][0] = "Nanjing is the capital of Jiangsu Province, the ancient capital of six dynasties, with rich historical relics and profound cultural heritage ";
descriptions[0][1] = "Taizhou is a thousand-year-old county, where Chairman Hu was born, and the hometown of Teacher Wang. It is famous for its three kinds of mahjong, especially mahjong.";
descriptions[0][ 2] = "There is heaven above, and there are Suzhou and Hangzhou below. Suzhou is famous for its gardens. Famous gardens include "Humble Administrator's Garden", "Lion Grove", etc., with outstanding people and literati.";
descriptions[1] = new Array();
descriptions[1][0] = "Hangzhou is the capital of Zhejiang Province, with beautiful scenery and a paradise on earth. It is said that "there is heaven above, and Suzhou and Hangzhou below.";
descriptions[ 1][1] = "Wenzhou is most famous for its businessmen. Almost everyone in Wenzhou is engaged in business. The Wenzhou real estate speculators who are hated by the whole country are the representatives! ";
descriptions[1][2] = "My understanding of Jiaxing is still at the historic conference held on Jiaxing South Lake";
descriptions[2] = new Array();
descriptions[2][0] = "Guangzhou is the capital of Guangdong Province, with a developed economy, but rampant crime! ";
descriptions[2][1] = "Shenzhen is the first special economic zone in the country. It has a developed economy and is almost entirely populated by immigrants. Like Guangzhou, the public security is not good. ";
descriptions[2][2] = "Zhuhai is one of the first coastal open cities in my country. It is a beautiful city, a typical coastal city, and suitable for living. ";
var current_province;
var current_city;
function setCity(province, city)
{
// alert("city");
//frame_b
var obj = window.frames.frame_b.document.getElementById("s2");
var length = cities[province].length;
for(i = 0; i < length; i) {
obj[i] = new Option(cities[province][i]);
obj[i].selected = "false";
}
obj[city].selected = true;
current_city = city;
setCityDescription(province, city);
}
function setCityDescription(province, city)
{
// alert("description");
//frame_c
var obj = window.frames.frame_c.document.getElementById("description");
obj.innerHTML = descriptions[province][city];
}
function setProvince(province)
{
// alert("province");
// var obj = window.frames.frame_a.document.getElementById("s1");
/ / var obj = window.frames["frame_a"].document.getElementById("s1");
//var obj = window.frames[0].document.getElementById("s1");
/ / var obj = window.frames["frame_a"]; //.document.getElementById("s1");
// obj = obj.document.getElementById("s1");
var obj = window .frames["frame_a"].document.getElementById("s1"); //Since Chrome's check for cross-domain access cannot be displayed locally, it will be displayed correctly when uploaded to the server.
var length = provinces.length;
for(i = 0; i < length; i) {
obj[i] = new Option(provinces[i]);
obj[i ].selected = "false";
}
obj[province].selected = "true";
current_province = province;
var city = 0;
setCity(province, city) ;
//setCityDescription(province, city);
}
function init(province, city)
{
setProvince(province);
setCity(province, city );
setCityDescription(province, city);
var obj = window.frames.frame_a.document.getElementById("s1");
obj.onchange = Function("setProvince(this.selectedIndex)" );
// alert(obj.selectedIndex);
var obj = window.frames.frame_b.document.getElementById("s2");
obj.onchange = Function("setCity( current_province, this.selectedIndex)");
// alert(obj.selectedIndex);
}
5. Postscript :
1) Flexibility: function init(province, city) When the page is onloaded, you can specify the city to be initially displayed. Bidding ranking.
2) Scalability: Support for more cities can be added by adding data sources in the array. Data sources can be dynamic data sources through xml files or ajax, and can be implemented using dom operations.
3) Cross-domain problem: Since Chrome performs cross-domain inspection on the frame, the page cannot be displayed without setting it locally. However, I can upload it to the server, no problem.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.
