casa
12-01-2003, 03:19 PM
I am dynamically buiding an html form with php. I'm reading a db table field which has a set of codes delimited by a pipe. If the code is 1-2 characters long it's a group and it it's 3-4 characters long it's a deparment within a particular group. My form goes something like this:
-----------------------------------------------------
Date Range: [ Select a Date Range |v]
Group or
Department: [ ] AD select as
[ ] BD many as
[ ] CD01 needed
[ ] CD02
[ ] CD10
-----------------------------------------------------
[ Select ] [ Reset ]
-----------------------------------------------------
In this case, I would have two hidden fields,
<input type="hidden" name="GR" value=2>
<input type="hidden" name="DP" value=3>
so I would know how many possible fields there would be.
The user could select all or any combination of these 5 checkboxes, however, they have to select at least on. Right now, I have them set like this:
<input type="checkbox" name="G1" value="AD">
<input type="checkbox" name="G2" value="BD">
<input type="checkbox" name="D1" value="CD01">
<input type="checkbox" name="D2" value="CD02">
<input type="checkbox" name="D3" value="CD10">
I can't figure out how to validate this correctly. I was thinking about something like:
<input type="checkbox" name="G[1]" value="AD">
<input type="checkbox" name="G[2]" value="BD">
<input type="checkbox" name="D[1]" value="CD01">
<input type="checkbox" name="D[2]" value="CD02">
<input type="checkbox" name="D[3]" value="CD10">
But am not sure exactly how that works. Any pointers or advice would be greatly appreciated.
Thanks,
casa
-----------------------------------------------------
Date Range: [ Select a Date Range |v]
Group or
Department: [ ] AD select as
[ ] BD many as
[ ] CD01 needed
[ ] CD02
[ ] CD10
-----------------------------------------------------
[ Select ] [ Reset ]
-----------------------------------------------------
In this case, I would have two hidden fields,
<input type="hidden" name="GR" value=2>
<input type="hidden" name="DP" value=3>
so I would know how many possible fields there would be.
The user could select all or any combination of these 5 checkboxes, however, they have to select at least on. Right now, I have them set like this:
<input type="checkbox" name="G1" value="AD">
<input type="checkbox" name="G2" value="BD">
<input type="checkbox" name="D1" value="CD01">
<input type="checkbox" name="D2" value="CD02">
<input type="checkbox" name="D3" value="CD10">
I can't figure out how to validate this correctly. I was thinking about something like:
<input type="checkbox" name="G[1]" value="AD">
<input type="checkbox" name="G[2]" value="BD">
<input type="checkbox" name="D[1]" value="CD01">
<input type="checkbox" name="D[2]" value="CD02">
<input type="checkbox" name="D[3]" value="CD10">
But am not sure exactly how that works. Any pointers or advice would be greatly appreciated.
Thanks,
casa