我已成立了代表一个空白的PDF页面,用户可以使用单选按钮,横向或纵向的方向使用使用单选按钮和个人的动机和目标陈述选择纸张大小工作区复选框。用户选中/取消选中他们希望放置在工作区上的语句,也可以拖放它们。jQuery的模拟点击,复选框,并调用函数
当用户改变了方向,我需要简单地保存所有选中的报表项目,其中我把到一个数组。然后取消选中所有被选择添加的语句的复选框(这是有效的),并从工作区中删除所有语句(这不起作用)。然后,我需要循环访问数组以返回并检查复选框(这起作用)并调用BoardElement函数(这不起作用)来运行ajax调用。
我使用的相关代码如下,并尝试了不同帖子的许多建议。 OrientationChange函数是我用来尝试保存,移除并调用BoardElement来获取元素的。
谢谢。
HTML
<h3>Paper Size</h3>
<input type="radio" name="paper_size" id="paper_size1" value="8-5x11" checked="checked" />
8.5"x11"
<input type="radio" name="paper_size" id="paper_size2" value="11x17" />
11"x17"
</fieldset>
<fieldset>
<h3>Orientation</h3>
<input type="radio" name="orientation" id="orientation1" value="l" checked="checked" /> Landscape
<input type="radio" name="orientation" id="orientation2" value="p" /> Portrait
</fieldset>
<fieldset>
<h3>Elements</h3>
<input type="checkbox" name="board_element_cb" id="board_ele_0" value="0" /> "Who Am I" Image
<input type="checkbox" name="board_element_cb" id="board_ele_1" value="1" /> "Who Am I" Text
<input type="checkbox" name="board_element_cb" id="board_ele_2" value="2" /> Mission Statement
</fieldset>
jQuery的
$(document).ready
(
function()
{
BoardElement = function()
{
var elements_array = new Array('wai_img_', 'wai_text_', 'mission_text_', 'affirmation_text_', 'gratitude_text_', 'role_model_');
if ($(this).is(':checked'))
{
var data_string = 'board_element=' + $(this).val();
$.ajax
({
type: 'POST',
url: 'get_board_element_ajax.php',
data: data_string,
success: function(html)
{
$('#board_area').append(html);
$('.draggable_item').draggable
({
containment: '#board_area',
stack: '#board_area div'
});
}
});
}
else
{
var checked_value = $(this).val();
$('.draggable_item').each
(
function()
{
if (this.id.indexOf(elements_array[checked_value]) > -1)
{
$('#' + this.id).remove();
}
});
}
}
$('input[id^=board_ele_]').click(BoardElement);
// save, remove and get selected board items on orientation change
OrientationChange = function()
{
var board_ele_array = new Array();
// save
$('input[id^=board_ele_]').each
(
function (i)
{
if ($('#board_ele_' + i).is(':checked'))
{
$('#board_ele_' + i).attr('checked', false);
board_ele_array.push(i);
$('#board_ele_' + i).attr('checked', false);
}
});
//for (var j = 0; j < board_ele_array.length; j++)
//{
var j = 0;
function BoardEleCheckbox()
{
if (j < board_ele_array.length)
{
$('#board_ele_' + board_ele_array[j]).attr('checked', true);
//$('#board_ele_' + board_ele_array[j]).click();
//BoardElement();
$('#board_ele_' + board_ele_array[j]).click(BoardElement);
j++;
setTimeout(BoardEleCheckbox, 1000);
}
}
setTimeout(BoardEleCheckbox, 1000);
//}
}
$('input[name=orientation]').click(OrientationChange);
});
您是否可以尝试将预期过程(包括什么是和不在工作)作为清晰的项目符号列表进行修改,并在某种程度上阐明该语言。试图以目前的形式遵循它是非常混乱的。 –
使这个问题清楚...它太凌乱了解 – Varun
请分享html代码以及... – Varun