jQuery-option-tree联动下拉框

徐杰
2023-12-01

挺好用的jquery实现联动下拉框:

<html>
	<head>   
		 
		<script type="text/javascript" src="jquery-1.6.2.js"></script>
		<script type="text/javascript" src="jquery.optionTree.js"></script>    
		

	</head> 

	<body>
	<h3>Demo1</h3>
		<input type="text" name="demo1" />
		<script type="text/javascript">
			$(function() {

				var option_tree = {
				   "Option 1": {"Suboption":200},
				   "Option 2": {"Suboption 2": {"Subsub 1":201, "Subsub 2":202},
							"Suboption 3": {"Subsub 3":203, "Subsub 4":204, "Subsub 5":205}
						   }
				};

				$('input[name=demo1]').optionTree(option_tree);

			});
		</script>

		<br>
		<h3>Demo2</h3>
		<input type="text" name="demo2" />
		<script type="text/javascript">
			var option_tree = {
			   "Option 1": {"Suboption":200},
			   "Option 2": {"Suboption 2": {"Subsub 1":201, "Subsub 2":202},
						"Suboption 3": {"Subsub 3":203, "Subsub 4":204, "Subsub 5":205}
					   }
			};

			var options = {empty_value: -1, choose: '...select'};

			$('input[name=demo2]').optionTree(option_tree, options)
								 ;
		</script>

	</body>
</html>

 

还有其他demo,ajax实现等参看连接:

http://code.google.com/p/jquery-option-tree/

 类似资料: