我试图使用jquery检查/取消选中所有复选框.现在通过选中/取消选中父复选框,所有子复选框都被选中/取消选中,父复选框的文本也变为checkall/uncheckall.
现在我想用输入按钮替换父复选框,并更改按钮上的文本以checkall/uncheckall.这个代码,任何人都可以调整代码....
$( function() {
$( '.checkAll' ).live( 'change', function() {
$( '.cb-element' ).attr( 'checked', $( this ).is( ':checked' ) ? 'checked' : '' );
$( this ).next().text( $( this ).is( ':checked' ) ? 'Uncheck All' : 'Check All' );
});
$( '.cb-element' ).live( 'change', function() {
$( '.cb-element' ).length == $( '.cb-element:checked' ).length ? $( '.checkAll' ).attr( 'checked', 'checked' ).next().text( 'Uncheck All' ) : $( '.checkAll' ).attr( 'checked', '' ).next().text( 'Check All' );
});
});
<input type="checkbox" class="checkAll" /> …
Run Code Online (Sandbox Code Playgroud) 如果我第一次设置一个单选按钮,它可以正常工作.但如果我通过调用((RadioButton)findViewById(R.id.ID))取消选择它.setChecked(false); 然后,即使我尝试通过调用setChecked(true)来选择它也不会工作,除非用户从屏幕上选择它.
有没有人碰到过这个?还是只有我?
if(Val != null){
if( ((RadioButton) findViewById(R.id.ID1)).getText().toString().trim().equals(Val))
((RadioButton) findViewById(R.id.ID1)).setChecked(true);
else if(((RadioButton) findViewById(R.id.ID2)).getText().toString().trim().equals(Val))
((RadioButton) findViewById(R.id.ID2)).setChecked(true);
}
else {
((RadioButton) findViewById(R.id.ID1)).setChecked(false);
((RadioButton) findViewById(R.id.ID2)).setChecked(false);
}
Run Code Online (Sandbox Code Playgroud)
如果else部分至少执行一次,那么一切都会变得混乱.当我进入调试器时,我可以看到执行进入正确的路径并将其设置为true.它只被执行一次,我检查了一下.而且我没有在代码的任何其他部分将其重置为false.
我有html项目,4个示例:
<div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
<div><input type="checkbox" class="foo"> Checkbox</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在,我想要下一个:如果我点击任何复选框 - 应选中复选框,并取消选中其他复选框.我该怎么做?
我在weblogic上运行了一个j2ee应用程序.我对我的multibox感到困惑.
我所知道的multibox是被检查的项目将在提交时作为字符串数组传递.
我不知道为什么在我的应用程序中,当我取消选中一个复选框或更多时,它工作正常,只要一个盒子仍然被选中但是当我取消选中所有内容时,提交的数组是先前检查过的多盒子的数组,当它应该是是空的.
你能帮我吗?
我正在登录屏幕上,您基本上可以选择是否需要4位PIN访问权限或刷卡方法安全性; 我希望这样看的方式是布局中有两个复选框,最初它们都是未选中的.当您选择一个时,它会被检查,但如果您尝试选择另一个,它会自动取消选中第一个.我在布局中定义了两个复选框,但是我有点困惑的是我必须引用强制取消选中的内容.
public void onCheckBoxClicked(View view){
boolean checked = ((CheckBox)view).isChecked();
switch(view.getId()){
case R.id.setupCheckBox1:
if(checked){
}
Run Code Online (Sandbox Code Playgroud)
基本上,我知道如果{}语句自动取消检查setupCheckBox2,那么必须要考虑的事情,但我只是不确定必须做什么是假的.任何帮助赞赏!
此外,我意识到这是一个单行答案,如果有人对Android中的复选框有任何好的参考,我也不介意阅读,我对这些东西有点新鲜.
该应用程序是一个步进音序器应用程序,具有16个无线电组,每组有8个按钮.除非我使用我创建的清除按钮清除所有放射线组,否则除非一个组选择了一个按钮,否则它可以完美地工作.我想要添加的是一些代码,表示当再次选择所选单选按钮时,它会像切换一样关闭.我尝试使用切换,但随后出现了其他问题.下面是对它的一次尝试但是我猜测它是不合适的
final RadioGroup radioGroup1 = (RadioGroup)findViewById(R.id.RadioGroup1);
RadioButton lC1 = (RadioButton)findViewById(R.id.RadioButtonlowC1);
Button D1 = (Button)findViewById(R.id.RadioButtonD1);
D1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PdBase.sendFloat("D1", 74);
int selectedTypeId = radioGroup1.getCheckedRadioButtonId();
RadioButton D1 = (RadioButton) findViewById(selectedTypeId);
if(radioGroup1 != null) // This will be null if none of the radio buttons are selected
radioGroup1.clearCheck();
PdBase.sendFloat("D1", 0);
}
});
Run Code Online (Sandbox Code Playgroud) 基本上我有3个复选框.它们中的每一个都有一个布尔值,当单击一个按钮并选中该框时,该布尔值将变为true.
但是,当取消选中复选框而不必先触摸另一个按钮来触发事件时,可以执行操作.
例如:我选中复选框1和2. =>我点击开始按钮 - >布尔值复选框1和2设置为true.=>我取消选中复选框2 - >触发事件
我有多个复选框.当我点击相应的按钮时,我想检查并取消选中其中一些或全部.
例如,当我点击"全部检查"按钮时,我想要检查所有按钮.当我点击"男性"按钮时,我只想检查"类"等于"男性"的复选框.当我点击"女性"按钮时,我只想检查类等于"女性"的复选框.当我点击"无"按钮时,我只想检查类等于"无"的复选框.我怎么能用jquery做到这一点?
<br>
<div>
<input type="checkbox" class="check_all"> Check all
<input type="checkbox" class="check_all_females"> Females
<input type="checkbox" class="check_all_males"> Males
<input type="checkbox" class="check_all_none"> None
</div>
<input type="checkbox" class='male'> John<BR>
<input type="checkbox" class='male'> Maria<BR>
<input type="checkbox" class='male'> Ali<BR>
<input type="checkbox" class='male'> Tural<BR>
<input type="checkbox" class='female'> John<BR>
<input type="checkbox" class='female'> Fuass<BR>
<input type="checkbox" class='female'> Jadsa<BR>
<input type="checkbox" class='none'> Dasda<BR>
<input type="checkbox" class='none'> Wers<BR>
<input type="checkbox" class='none'> Saqa<BR>
Run Code Online (Sandbox Code Playgroud) 我想在customlistview.my适配器中取消选中复选框工作正常,然后单击按钮
这是在我的按钮监听器中写的
for(int i = 0; i<listview.getChildCount();i++)
{
v = listview.getChildAt(i);
CheckBox cv =(CheckBox)v.findViewById(R.id.checktitle);
if(cv.isChecked())
{
// cv.setChecked(false);
//listview.setItemChecked(i, false);
toggle(cv);
}
Run Code Online (Sandbox Code Playgroud)
在切换方法中
public void toggle(CheckBox v)
{
if (v.isChecked())
{
v.setChecked(false);
}
else
{
v.setChecked(true);
}
}
Run Code Online (Sandbox Code Playgroud)
适配器
public class customAdapter extends ArrayAdapter {
View view=null;
Context context;
ViewHolder holder; boolean checkAll_flag = false;
boolean checkItem_flag = false;
List<CustomDishMenus> dcates=new ArrayList<CustomDishMenus>();
public customAdapter(Context context, int textViewResourceId, List objects) {
super(context, textViewResourceId, objects);
// TODO Auto-generated constructor stub
this.context=context;
this.dcates=objects; …
Run Code Online (Sandbox Code Playgroud) 我正在使用ajax加载动态生成的单选按钮,当我尝试取消选中单选按钮时,我不知道它是如何工作的.所以有人可以帮助我吗?
这是动态生成的HTML代码:
enter code here
<table cellepadding='15' cellspacing='15' border='1' class='gridtable' align='center'>
<tr>
<td><strong>Service Name</strong></td>
<td><strong>Daily</strong>
<td><strong>Weekly</strong></td>
<td><strong>BiMonthly</strong></td>
<td><strong>Monthly</strong></td>
</tr>
<tr>
<td>Inspection & Reporting</td>
<td>NA</td>
<td align="center">
<input type="radio" id="215" name="1" value="1/215" onclick="DisplayPrice(this.id);" class="radio"/> <br> Rs. <strong>50</strong></td>
<td><input type="radio" id="200" name="1" value="2/200" onclick="DisplayPrice(this.id);" class="radio"/> <br> Rs. <strong>100</strong></td>
<td align="center"><input type="radio" id="200" name="1" value="3/200" onclick="DisplayPrice(this.id);" class="radio"/> <br> Rs. <strong>200</strong></td>
</tr>
<tr>
<td>House keeping/Cleaning</td>
<td>NA</td>
<td align="center"><input type="radio" id="322.5" name="2" value="7/322.5" onclick="DisplayPrice(this.id);" class="radio"/> <br> Rs. <strong>75</strong></td>
<td><input type="radio" id="300" name="2" value="8/300" onclick="DisplayPrice(this.id);" class="radio"/> …
Run Code Online (Sandbox Code Playgroud) uncheck ×10
checkbox ×6
android ×4
jquery ×4
radio-button ×3
action ×1
checked ×1
html ×1
if-statement ×1
javascript ×1
layout ×1
listview ×1
multibox ×1
struts ×1