Well, I miserably failed...
I took all the code from the article and put it all in a test.php file. The only modification I made was to post on itself.
<script language="JavaScript1.2" type="text/javascript">
function allSelect()
{
List = document.forms[0].test_select;
if (List.length && List.options[0].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
</script>
<form action="<? print($_SERVER['PHP_SELF']); ?>" method="post" name="frm_test" id="frm_test" enctype="application/x-www-form-urlencoded" onSubmit="return allSelect();">
<select name="test_select[]" id="test_select" multiple="multiple">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input type="Submit" name="btn_submit" id="btn_submit" value="Submit" />
</form>
<?
if (is_array(test_select[])) { // is this an array?
$selects = sizeof(test_select[]); // get the size of the submitted array (i.e. how many content items were submitted for the home page)
for ($i=0; $i<$selects; $i++) { // ok loop over it
echo($test_select[$i]."<br />"); // and output it to screen
}
}
?>
When I tested it I keep getting an error:
Parse error: parse error, unexpected '[' in /home/dir/test.php on line 24
Something tells me there's gotta be a simpler way to do multiple selects in HPP without involving JS...