Basically I want to create a form that on submit would create a new form based on the checklist selection.
For instance, when looking at my code, if I checked Section 1, Test Item 2 and submitted it. On submit it would pull up a new page (or load onto the current page) the more in depth steps. I'm trying to make a template to use on multiple documents, so just adding it in right there won't do it for me.
(1) How do I make Section 1, 2, and 3 to have nothing until checked? Instead of having to click the checkbox twice to make it go away, I'd rather have it not be there and appear when checked.
(2) I want the All checklist to check all the boxes but not show or hide them (I know this isn't coded right for this but I don't know how)
Here's my code: http://jsfiddle.net/kNsW9/2/
<script>
$(document).ready(function(){
$('#all').click(function(){
if ($('#all').is(':checked'))
$(this).nextAll('li').show();
else
$(this).nextAll('li').hide();
});
$('#1').click(function(){
if ($('#1').is(':checked'))
$(this).nextUntil('ol').show();
else
$(this).nextUntil('ol').hide();
});
$('#2').click(function(){
if ($('#2').is(':checked'))
$(this).nextUntil('ol').show();
else
$(this).nextUntil('ol').hide();
});
$('#3').click(function(){
if ($('#3').is(':checked'))
$(this).nextUntil('ol').show();
else
$(this).nextUntil('ol').hide();
});
});
</script>
<form>
Table of Contents<br />
Please Select What to Test:<br />
<input type="checkbox" id="all" onclick="check(this.id)"></input>All
<ol><input type="checkbox" id="1"></input>Section 1
<li><input type="checkbox"></input>Test Item 1</li>
<li><input type="checkbox"></input>Test Item 2</li>
</ol>
<ol><input type="checkbox" id="2"></input>Section 2
<li><input type="checkbox"></input>Test Item 1</li>
<li><input type="checkbox"></input>Test Item 2</li>
<li><input type="checkbox"></input>Test Item 3</li>
<li><input type="checkbox"></input>Test Item 4</li>
<li><input type="checkbox"></input>Test Item 5</li>
<li><input type="checkbox"></input>Test Item 6</li>
</ol>
<ol><input type="checkbox" id="3"></input>Section 3
<li><input type="checkbox"></input>Test Item 1</li>
<li><input type="checkbox"></input>Test Item 2</li>
<li><input type="checkbox"></input>Test Item 3</li>
<li><input type="checkbox"></input>Test Item 4</li>
<li><input type="checkbox"></input>Test Item 5</li>
</ol>
<!--<input type="submit" value="Submit">-->
</form>
Let me know how this works for you...
*I updated with css controlling the LI's visibilty instead of jquery Checking all will check all sub items, unchecking all will uncheck all sub items
*I'm assuming that if you check all, then uncheck a subitem that all should be unchecked as well, right?
$('#all').click(function(){
var checked = $(this).prop('checked');
$('#section1,#section2,#section3').each(function() {
$(this).find('input:checkbox').prop('checked', checked);
});
});
I Made some changes in your jsfiddle, not sure if this is what your looking for. let me know if this is it or if I misunderstood the question:
DEMO: http://jsfiddle.net/kNsW9/4/
you are in the right direction just had to make small changes
$('#1').nextUntil('ol').hide()
$('#2').nextUntil('ol').hide();
$('#3').nextUntil('ol').hide();
$('#all').click(function(){
$('#1').click();
$('#2').click();
$('#3').click();
});