Im developing an online booking system and having a problem with my final booking form. basically what happens is that the user selects the dates they want by selecting the checkbox that corresponds with the date above it. the checkboxes have a value of the price of the room for that night.

Im using javascript to total the value for the selected dates but i also need a script that will select the first and last hidden date field that corresponds with the selected checkboxes so that there is an arrival date and a departure date. Im pretty new to javascript and some help would really be appreciated. This is just a really simplified version but everything is there that is needed.

Cheers
Shaun

PHP Code:
<form name="form2">
for($i=0;$i<28;$i++)
{
//Array of dates fot the next 28 days
<input type="hidden" 
name="date<?php print $i?>
id="date<?php print $i?>"
value="<?php print $dt?>" />
}

for($i=0;$i<28;$i++)
{
//Array of hotel room prices for the next 28 days
<input type="checkbox" 
id="day<?php print $dayno;?>
name="day<?php print $dayno;?>
value="<?php print substr($price->$_GET['days'],0,3); ?>"
onclick="changeCheckbox(0);" />
}
</form>

<form name="theform">
  <table>
    <tr> 
      <td>
        <div>Arrival Date
        </div>
      </td>
      <td> 
        <input type="text" name="arrival" value"" readonly="">
        <input type="hidden" name="arrival_date" value="">
      </td>
      <td>
        <div>Departure Date
        </div>
      </td>
      <td>
        <input type="text" name="departure" value"" readonly="">
        <input type="hidden" name="departure_date" value="">
      </td>
    </tr>
  </table>
</form>