$(document).ready(function() {
if (jQuery.url.param('checkboxname') == 'checkboxvalue') {
$('#msgdiv').show();
} else {
$('#msgdiv').hide();
}
});
<body> <form method="get" action="next-page.html"> <input type="checkbox" id="box_1" name="box_1" value="1"><label for="box_1">Box 1</label> <input type="checkbox" id="box_2" name="box_2" value="1"><label for="box_2">Box 2</label> <input type="checkbox" id="box_3" name="box_3" value="1"><label for="box_3">Box 3</label> <input type="checkbox" id="box_4" name="box_4" value="1"><label for="box_4">Box 4</label> <input type="submit" value="Go"> </form> </body>Here's your next-page.html:
<style type="text/css">
#conditional-divs>div {
display: none;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var parts = document.location.search.substring(1).split("&");
for (i = 0; i < parts.length; i++) {
var selector = '#' + parts[i].split("=")[0];
$(selector).show();
}
});
</script>
<body>
<div id="conditional-divs">
<div id="box_1">div_1</div>
<div id="box_2">div_2</div>
<div id="box_3">div_3</div>
<div id="box_4">div_4</div>
</div>
</body>
I suppose you could submit the form via GET, and then use something like this jQuery URL Parser to get the submitted values from the form, but that's a really roundabout way to do things.
posted by le morte de bea arthur at 7:37 AM on July 21, 2010