早就利用了 j来这样做,但现在我需要这样做,因为文件缺乏,所以它带有图形,很少被混淆。
我有2个检查箱清单。
第一清单:
Check box 1
Check box 2
第二个名单:
Check box x
check box y
check box z
我需要联合工作组的守则,使用原型来开展这项工作: 第二份名单仍然残疾,除非我检查第一份名单的检查箱之一。
任何建议?
早就利用了 j来这样做,但现在我需要这样做,因为文件缺乏,所以它带有图形,很少被混淆。
我有2个检查箱清单。
第一清单:
Check box 1
Check box 2
第二个名单:
Check box x
check box y
check box z
我需要联合工作组的守则,使用原型来开展这项工作: 第二份名单仍然残疾,除非我检查第一份名单的检查箱之一。
任何建议?
Here本法典:
Event.observe(window, load , function(){
// for all items in the group_first class
$$( .group_first ).each(function(chk1){
// watch for clicks
chk1.observe( click , function(evt){
// count how many of group_first
// are checked, true if any are checked
var doEnable = ($$( .group_first:checked ).length > 0);
// for each in group_second, enable the
// checkbox, and remove the cssDisabled class
$$( .group_second ).each(function(item){
if (doEnable) {
item.enable().up( label ).removeClassName( cssDisabled );
} else {
item.disable().up( label ).addClassName( cssDisabled );
}
});
});
});
});
根据这一超文本:
<fieldset>
<legend>First Group</legend>
<label><input type="checkbox" value="1"
class="group_first" />Check box 1</label><br />
<label><input type="checkbox" value="2"
class="group_first" />Check box 2</label>
</fieldset>
<fieldset>
<legend>Second Group</legend>
<label class="cssDisabled"><input type="checkbox" value="x"
class="group_second" disabled="disabled" />Check box x</label><br />
<label class="cssDisabled"><input type="checkbox" value="y"
class="group_second" disabled="disabled" />Check box y</label><br />
<label class="cssDisabled"><input type="checkbox" value="z"
class="group_second" disabled="disabled" />Check box z</label>
</fieldset>
加入本中心:
.cssDisabled { color: #ccc; }
原型文件非常好。 这里使用的是:
对于有兴趣在酒类中如何做到这一点的人:
jQuery(document).ready(function(){
$( .group_first ).bind( click , function(){
var doEnable = ($( .group_first:checked ).length > 0);
$( .group_second ).each(function(){
if (doEnable) {
$(this).attr( disabled , null);
$(this).parents( label ).removeClass( cssDisabled );
} else {
$(this).attr( disabled , disabled );
$(this).parents( label ).addClass( cssDisabled );
}
});
});
});
这是测试代码Ive建造和检查第1组检查箱,不能使第2组检查箱进入。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>toggle disabled</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="prototype.js" type="text/javascript">
<script type="text/javascript">
var checkboxes = $$( input[name="group1"] );
checkboxes.each(function(s) {
s.observe( click , function() {
if(this.checked) {
$$( input[name="group2"] ).each(function(s) {
s.enable();
});
} else {
if(!$$( input[name="group2"][checked="checked"] ).length) {
alert( nothing checked );
$$( input[name="group2"] ).each(function(s) {
s.disable();
});
}
}
});
});
</script>
</head>
<body>
<div>
<label> Group 1 </label>
<input type="checkbox" name="group1" value="test"/>
<input type="checkbox" name="group1" value="test"/>
<input type="checkbox" name="group1" value="test"/>
</div>
<div>
<label> Group 2 </label>
<input type="checkbox" name="group2" disabled="disabled"/>
<input type="checkbox" name="group2" disabled="disabled"/>
<input type="checkbox" name="group2" disabled="disabled"/>
</div>
</body>
</html>
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...
<form><input type="file" name="first" onchange="jsFunction(2);"> <input type="file" name="second" onchange="jsFunction(3);"</form> Possible to pass just numbers to the js ...
So I ve got a menu with a hover/selected state and it loads fine in IE6/IE7. However when I scroll down the page and put the element outside of the viewport and then back in I get a broken image! I ...
I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!