日期:2014-05-17  浏览次数:20549 次

动态生成html页面(四)
补充一下js

<script>
	function toggleDisabled(tag){
				var cid = $(tag).attr("id");
				var checked = Tag.getChecked(cid);
				var pid = cid.split("_")[0];
				var ppid;
				$.each($("." + pid + "_param"), function(i, n){
					ppid = $(n).attr("id");
					Tag.setDisableds([ppid + "_unit", ppid + "_int", ppid + "_radio"], !checked);
					$("#" + ppid + "_th").attr("style", checked ? "" : "color: grey");
					$.each($("." + ppid + "_radio"), function(i, n){
						Tag.setDisabled($(n).attr("id"), !checked);
					});
				});
				
			}

			function lookData(){
				var s = "";
				var pid;
				var ppid;
				var name;
				var value;
				var unit;
				$.each($(".policy_head"), function(i, n){
					pid = $(n).attr("id");
					if (Tag.getChecked(pid)){
						s += "<policy name='" + pid + "' readonly='true' >\n";
						$.each($("." + pid + "_param"), function(i, n){
							ppid = $(n).attr("id");
							name = ppid.split("_")[1];
							value = $("#" + ppid + "_" + $("#" + ppid + "_type").val()).val();
							s += "<param name='" + name + "' value='" + value + "'";
							if ($("#" + ppid + "_unit").length != 0){
								unit = Tag.getCombValue(ppid + "_unit");
								s += "unit='" + unit + "'";
							}
							s += " />\n";
						});
						s += "</policy>\n";
					}
				});
				alert(s);
			}
		</script>