If you mean can you collect a sub-set of options within a select
box of a form, then yes, I believe you can:
<form method="post" action="" enctype="form/multipart">
<fieldset>
<select>
<optgroup label="numbers">
<option>One</option>
<option>Two</option>
<option>Three</option>
</optgroup>
<optgroup label="letters">
<option>a</option>
<option>b</option>
<option>c</option>
</optgroup>
</select>
</fieldset>
</form>
demo at: http://jsbin.com/iwada3/edit
Edited after realising I'm a moron, and addressing the question that was really asked (I'm sorry, long day...):
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
$('option.all').click(
function() {
$(this).parent().children().attr('selected','selected');
$(this).attr('selected','');
}
);
}
);
</script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
</head>
<body>
<form>
<fieldset>
<select multiple>
<optgroup class="num" label="numbers">
<option class="num all">Select all:</option>
<option class="num">One</option>
<option class="num">Two</option>
<option class="num">Three</option>
</optgroup>
<optgroup class="let"label="letters">
<option class="let all">Select all:</option>
<option class="let">a</option>
<option class="let">b</option>
<option class="let">c</option>
</optgroup>
</select>
</fieldset>
</form>
</body>
</html>
Demo at: http://jsbin.com/ebeke3
It does require jQuery (in this version, at least), but I can't see an alternative to JS for what you require, I'm sorry to say.
If you mean something else, then I'm not sure I understand the question.