<select name="status" id='status'>
<option value="Submitted">Submitted</option>
<option value="Canceled">Canceled</option>
</select>
<input type="checkbox" id="app_box" name="application_complete" value="checked"> App Complete
<script type="text/javascript">
$(function() {
$('form.editable').submit(function(){
if ($('#status').val()=='Canceled') {
if (!confirm('This information will be discarded! )) {
return false;
}
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
所以,我有上面的脚本工作正常.我还要再添一个确认.当代理点击提交按钮时,我想检查是否选中了应用程序复选框.如果未选中,则显示另一个确认框,说明您必须选中该复选框.怎么能在jquery中完成.
我在数据库表中有位置名称和位置ID.使用foreach循环我在PHP中的复选框中打印值.我有一个触发javascript的提交按钮.我希望用户在javascript变量中选择以逗号分隔的所有复选框值.我怎样才能做到这一点?
<!-- Javascript -->
<script>
function getLoc(){
var all_location_id = document.getElementByName("location[]").value;
var str = <!-- Here I want the selected checkbox values, eg: 1, 4, 6 -->
}
<script>
foreach($cityrows as $cityrow){
echo '<input type="checkbox" name="location[]" value="'.$cityrow['location_id'].'" />'.$cityrow['location'];
echo '<br>';
}
echo '<input name="searchDonor" type="button" class="button" value="Search Donor" onclick="getLoc()" />';
Run Code Online (Sandbox Code Playgroud) 我在验证是否使用Internet Explorer上的jquery检查复选框时遇到问题.这是我正在使用的代码:
if ($('#chkjq_1').attr('checked') == true)
Run Code Online (Sandbox Code Playgroud)
它在Firefox或Chrome上运行正常,但在Internet Explorer 7上,条件始终为false,因为浏览器以这种方式设置属性:
<input id="chkjq_1" type="checkbox" CHECKED/> IE7
Run Code Online (Sandbox Code Playgroud)
正确的方法如下:(Firefox,Chrome):
<input id="chkjq_1" type="checkbox" checked="checked"/> FF, Chrome, etc
Run Code Online (Sandbox Code Playgroud)
我应该怎么做才能在Internet Explorer 7上避免此问题; 在jquery中有一个通用的方法来解决这个问题吗?
提前致谢.
您好我正在构建一个带有1个复选框的表单.其余的表单字段工作正常,但无论是否选中该复选框,该值始终为"on".
我的代码:
<input id="checkbox_<?=$row['csid'];?>" type="checkbox" <?php if($row['feedbackVisible'] == 'yes') { echo "checked='true'";}?> >
Run Code Online (Sandbox Code Playgroud)
以及我如何通过jQuery获得价值:
var review_visible_website = $('#checkbox_'+ modalId).val();
Run Code Online (Sandbox Code Playgroud)
复选框开始检查,但如果我取消选中它,它仍然给我值'开'.我究竟做错了什么?
我想做一个法官,checkbox value = 2, selected.但是现在我的法官不行.
Jquery部分
if($('#select input').attr('value')=='2'){
$('#select input').attr('checked','checked');
}
Run Code Online (Sandbox Code Playgroud)
Html部分
<div id="select">
<input type="checkbox" name="my_check[]" value="1">item1</input>
<input type="checkbox" name="my_check[]" value="2">item2</input>
<input type="checkbox" name="my_check[]" value="3">item3</input>
<input type="checkbox" name="my_check[]" value="4">item4</input>
<input type="checkbox" name="my_check[]" value="5">item5</input>
</div>
Run Code Online (Sandbox Code Playgroud) 我有一个功能,没有使用此功能正确拾取复选框(如果选中):
function playerJson() {
players = [];
$('input[name=playerCheckList]').each(function () {
if ($(this).checked) {
players.push($(this).val());
}
});
return $.toJSON(players);
}
Run Code Online (Sandbox Code Playgroud)
我用这个功能检查所有按钮(正确)
$(function () {
$("#checkAllPlayers").click(function () {
$('input[name=playerCheckList]').each(function () {
$(this).prop('checked', true);
});
});
});
Run Code Online (Sandbox Code Playgroud)
如果我没有if语句:
if($(this).checked)
从第一段代码中,它正确地获取所有值(已检查或未检查)
所以,这个陈述可能是问题所在,但我不确定为什么.
谢谢
HTML代码:
<div class="checkbox" style=" float:left "></div>
<input type="checkbox" class="realcheckbox" id="financing" />
Run Code Online (Sandbox Code Playgroud)
jQuery代码:
$(".checkbox").click(function() {
var xchecked = $(this).siblings(".realcheckbox").attr("checked");
if (xchecked == false) {
$(this).css("background-image","url('checkboxselected.png')");
$(this).next(".realcheckbox").attr("checked",true);
}
else {
$(this).css("background-image","url('checkbox.png')");
$(this).next(".realcheckbox").attr("checked",false);
}
});
Run Code Online (Sandbox Code Playgroud)
点击假复选框不会检查真实的复选框,但是如果检查了真实的复选框,点击假的那个正在完成工作,意味着真正的一个未经检查,第一个有什么问题?
我正在使用带有JQuery mobile的HTML构建表单,以便表单可以在移动设备上使用.
我有通过电子邮件导出到CSV的表单.但是,如果未选中"复选框",则不会写入CSV文件.
我是否可以使用jQuery中的函数从已选中的复选框中提取值,使用标签中的值,并将未选中的框标记为Null或作为a,Space以便在将它们导入Excel时,它会注意到未检查值?
<label for="question4" class="input"> 4. What language (s) are you currently using? </label>
<fieldset data-role="controlgroup">
<legend>Multi select:</legend>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" value="english"/>
<label for="checkbox-1"> English</label>
<input type="checkbox" name="checkbox-2" id="checkbox-2" class="custom" />
<label for="checkbox-2">French</label>
<input type="checkbox" name="checkbox-3" id="checkbox-3" class="custom" />
<label for="checkbox-3">Spanish</label>
<input type="checkbox" name="checkbox-4" id="checkbox-4" class="custom" />
<label for="checkbox-4">Brazilian Portuguese</label>
<input type="checkbox" name="checkbox-5" id="checkbox-5" class="custom" />
<label for="checkbox-5">Italian</label>
<input type="checkbox" name="checkbox-6" id="checkbox-6" class="custom" />
<label for="checkbox-6">German</label>
<input type="checkbox" name="checkbox-7" id="checkbox-7" class="custom" /> …Run Code Online (Sandbox Code Playgroud) 我有一个变量,我已经存储了我的复选框ID,但在我试图检查复选框是否被选中时,它不能正常工作.
<script>
function check(){
var id = "checkbox1.0";
if($('#' + id).is(':checked')){alert("checked");}
}
</script>
<body>
<input type ="checkbox" id = "checkbox1.0">
<input type ="checkbox" id = "checkbox2.0" onclick="check()">
</body>
Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个脚本,检查是否使用jQuery $each函数检查复选框.Below 是HTML代码:
<tr>
<td class="categories">World</td>
<td class="category_enabled" style="float: right;">
<input type="checkbox"/>
</td>
</tr>
<tr>
<td class="categories">Economy</td>
<td class="category_enabled" style="float: right;">
<input type="checkbox"/>
</td>
</tr>
<tr>
<td class="categories">?????????</td>
<td class="category_enabled" style="float: right;">
<input type="checkbox"/>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我相信它就像(内部.each()):
if ($("find_specific_checkbox").is(":checked")){
console.log("Checked!");
}
Run Code Online (Sandbox Code Playgroud)
任何想法我怎么能这样做.我正在尝试几个小时,但还没有.
jquery ×10
checkbox ×6
javascript ×6
html ×4
php ×2
ajax ×1
css ×1
forms ×1
html-table ×1
select ×1