Hi,
What I've deon to overcome this issue is that when the form is built up I have check boxes to the left of textboxes or slect boxes or whatever. The controls to the right start off in a span with a display state of none. A sample section of a form would look lie this:
[html]
<div class="row">
<span class="label">
<label for="useSession">Session: </label>
<input id="useSession" class="check" type="checkbox" onclick="this.value=this.checked; toggleDisplayState('sessionList')" title="search on session" value="true" name="useSession"/>
</span>
<span id="sessionList" class="formw" name="sessionList" style="display: none;">
<select id="session" name="session">
<option value="1">Session 1</option>
<option value="2">Session 2</option>
</select>
</span>
</div>
[/html]
The onclick event of the check box could be used as the onchange evet of a text box. It calls a simple javascript function that looks like:
-
function toggleDisplayState(poObjectToDisplay)
-
{
-
-
var loObject = document.getElementById(poObjectToDisplay);
-
-
//test the current state of the object and toggle opposite state.
-
if (loObject.style.display != '' && loObject.style.display != 'none')
-
{
-
loObject.style.display = 'none';
-
}
-
else
-
{
-
loObject.style.display = 'inline';
-
}
-
}
-
This is a very simplistic solution but then when I check the post data I check the stae of the check box to see if I need to check the contents of the other control.
A more complex solution would be to have the onclick event call a javascript function that use the XMLHTTPRequets object to get the information that was required and then write the control only when it is needed. When it is not need simply write nothing back in place of the control definition. This process is essentially AJAX and may be overkill for your project. If you want to investigate the AJAX route I would be happy to help you out and even post some psuedo code.
Cheers
nathj