Php 如何更改下一个输入的值?
如何一对一地更改下一个输入的值 这段代码执行全部选中或全部取消选中,但我想一对一地选中或取消选中Php 如何更改下一个输入的值?,php,jquery,arrays,checkbox,Php,Jquery,Arrays,Checkbox,如何一对一地更改下一个输入的值 这段代码执行全部选中或全部取消选中,但我想一对一地选中或取消选中 jQuery(document).ready(function() { jQuery('#topluekle').click(function() { if(jQuery(this).attr('checked')) { jQuery('input:checkbox').attr('checked',true); jQ
jQuery(document).ready(function() {
jQuery('#topluekle').click(function() {
if(jQuery(this).attr('checked')) {
jQuery('input:checkbox').attr('checked',true);
jQuery('input:text').attr('value','E');
} else {
jQuery('input:checkbox').attr('checked',false);
jQuery('input:text').attr('value','H');
}
});
});
示例代码:
<form>
<? for($i=1;$i<=5;$i++) { ?>
<input type="checkbox" id="pgun[]" name="pgun[]">
<input size="1" type="text" name="degerler[]" id="degerler[]" value="H">
<br />
<? } ?>
<label class="checkbox">
<input type="checkbox" value="E" name="topluekle" id="topluekle">
Check / Uncheck All *
</label>
</form>
选中/取消选中全部*
试试看
使用like
并用在类似的地方
如果要更改每个复选框的值,请单击,然后可以尝试
jQuery(document).ready(function() {
jQuery('input[name="pgun[]"]').click(function() {
var newVal=$(this).next('input:text').val()=='E' ? 'H' : 'E';
$(this).next('input:text').val(newVal);
});
});
它将更改相应文本框的复选框值
jQuery(document).ready(function() {
var txtObj = $('input:text');
jQuery('input:checkbox').each(function(i){
jQuery(this).click(function(){
if(jQuery(this).attr('checked')) {
$(txtObj[i]).val("E");
} else {
$(txtObj[i]).val("H");
}
});
});
});
嗨,谢谢你的回答。我解决了jQuery('input[type=checkbox]').change(function(){valim=jQuery(this).next('input:text').val();if(valim==“E”){jQuery(this).next('input:text').val('E”);}else{jQuery(this).next('input:text').val(“E”);});
jQuery(document).ready(function() {
jQuery('#topluekle').click(function() {
if(jQuery(this).prop('checked')) {
jQuery('input:checkbox').prop('checked',true);
jQuery('input:text').val('E');
} else {
jQuery('input:checkbox').prop('checked',false);
jQuery('input:text').val('H');
}
});
});
jQuery(document).ready(function() {
jQuery('input[name="pgun[]"]').click(function() {
var newVal=$(this).next('input:text').val()=='E' ? 'H' : 'E';
$(this).next('input:text').val(newVal);
});
});
jQuery(document).ready(function() {
var txtObj = $('input:text');
jQuery('input:checkbox').each(function(i){
jQuery(this).click(function(){
if(jQuery(this).attr('checked')) {
$(txtObj[i]).val("E");
} else {
$(txtObj[i]).val("H");
}
});
});
});