用户可以单击的单选按钮的办公室列表将在div中显示办公室信息.我可以选择让用户将办公室添加到单选按钮列表中.当用户填写表单时,单选按钮成功添加到列表但单击功能不会触发,因此不会更新div中的办公室信息.当我单击其他单选按钮时,div会更新,就在我单击动态添加的单选按钮时.我尝试使用.delegate()点击功能,因为在初始页面加载后添加了单选按钮,但没有成功.
任何帮助将不胜感激!!!
如何添加单选按钮:
$(document).on("click", "#addOffice", function() {
var officeadd = $('#officeAddForm').serializeArray();
//console.log(officeadd);
$.ajax({
url: 'officeadd.php',
type: "POST",
data: officeadd,
dataType: "json",
success: function(data) {
console.log(data);
if(data.errorCode[0] === 'ok') {
console.log('NO ERRORS');
console.log(data.officeInfo[1]);
$('#officecontrolgroup > div.ui-controlgroup-controls').append('<input type="radio" name="office" id="office' + data.officeInfo[0] + '" value="' + data.officeInfo[0] + '"/><label for="office' + data.officeInfo[0] + '">' + data.officeInfo[1] + '</label>').trigger('create');
$('#officecontrolgroup').controlgroup("refresh");
$("#deliveryInstructions").trigger("updatelayout");
$('#officeAddForm').trigger('reset');
var $office = '#office'+ data.officeInfo[0];
console.log($office);
$(function(){
$($office).prop('checked', true).checkboxradio("refresh");
$($office).trigger('click');
})
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
单击名为office的单选按钮的功能:
$('input[name=office]:radio').on('click', function() …Run Code Online (Sandbox Code Playgroud) 我尝试迭代复选框组,如果每个组至少检查了一个框,我想将该产品信息添加到数组(upperOrder).我的代码的问题是它只添加了最后一个选中的复选框组(或者写了之前添加的组).
基本上我想要一个多维数组,主数组是upperOrder,子数组是每个产品的信息.
感谢并感谢任何人的帮助,或者如果有更好的方法来实现这一点,我将不胜感激任何建议!
HTML:
<form class="upperCheckboxForm" data-prodid="100" data-prodname="adams" id="group1">
<fieldset data-role="controlgroup">
<legend>Group 1:</legend>
<input type="checkbox" name="checkbox-v-2a" id="checkbox-v-2a" value="one" data-tooth-position="UR1">
<label for="checkbox-v-2a">One</label>
<input type="checkbox" name="checkbox-v-2b" id="checkbox-v-2b" value="two" data-tooth-position="UR2">
<label for="checkbox-v-2b">Two</label>
<input type="checkbox" name="checkbox-v-2c" id="checkbox-v-2c" value="three" data-tooth-position="UR3">
<label for="checkbox-v-2c">Three</label>
</fieldset>
</form>
<form class="upperCheckboxForm" data-prodid="101" data-prodname="lap" id="group2">
<fieldset data-role="controlgroup">
<legend>Group 2:</legend>
<input type="checkbox" name="checkbox-v-2a" id="checkbox-v-2a" value="four" data-tooth-position="UR4">
<label for="checkbox-v-2a">Four</label>
<input type="checkbox" name="checkbox-v-2b" id="checkbox-v-2b" value="five" data-tooth-position="UR5">
<label for="checkbox-v-2b">Five</label>
<input type="checkbox" name="checkbox-v-2c" id="checkbox-v-2c" value="six" data-tooth-position="UR6">
<label for="checkbox-v-2c">Six</label>
</fieldset>
</form>
<button id="submitPrintForm">Click</button>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$('#submitPrintForm').on('click', function() { …Run Code Online (Sandbox Code Playgroud) 我有一个带有弹出 div 的单页标记,其中包含用户可以用来更新他/她的帐户信息的表单。表单提交后,弹出窗口关闭,页面刷新,显示位于 li 中的更新信息(这似乎有效)。问题是,如果用户返回并尝试再次更新,弹出窗口中的按钮不会提交。
在此先感谢您的任何建议!!!
Javascript
$('#updateadmin').click(function() {
var admin = $('#adminform').serializeArray();
/*alert(admin);*/
$.ajax({
type: "POST",
url: 'adminupdate.php',
data: admin,
success: function(data) {
if(data=="success") {
$('#admindiv').popup('close');
$.mobile.changePage('companyinfo.php', {
allowSamePageTransition: true,
transition: 'none',
reloadPage: true,
changeHash: false
});
} else {
$('#adminupdatestatus').html(data).css({color: "red"}).fadeIn(1000);
}
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud) 我使用jQuery和Raphael来隐藏/显示基于选中的复选框的形状但我得到一个firebug错误.show(); /.hide(); 当我将变量赋值给复选框ID并尝试显示/隐藏时,它们不是函数.但是,当我直接传递形状变量名称并显示/隐藏它有效.
非常感谢第一种方法返回错误或指向教程的任何帮助.谢谢!
jQuery的:
var p = Raphael("test");
var square = p.rect(100, 100, 60, 60);
square.attr('fill', 'orange');
square.hide();
var circle = p.circle(250, 250, 60);
circle.attr('fill', 'yellow');
circle.show();
$("#shapePosition input[type=checkbox]").on('click', function () {
var $this = $(this);
var shapeId = $(this).attr('id');
if ($this.is(':checked')) {
alert(shapeId);
square.show(); //This works
shapeId.show(); //This does not work(Error type: is not a function)
} else {
shapeId.hide();
}
});
Run Code Online (Sandbox Code Playgroud)
小提琴: