Is there a term for an individual who is half way between a Newby and a Novice?
Anyway, getting down to business...
I am trying to develop an on-line application form for my company's website. In it I have a number of 'Yes/No' or 'Select This Option' type questions where if an option is checked it will disable/enable another. I ended up using ClientScriptBlocks of JavaScript to accomplish this behaviour instead of an ASP.NET solution. Something like:
function Q8OngoingClicked(source)
{
//disable end date selections if ongoing is checked
var oMonth = document.getElementById('lstQ8EndMonth');
var oDate = document.getElementById('lstQ8EndDate');
var oYear = document.getElementById('lstQ8EndYear');
if (source.checked)
{
oMonth.disabled = true;
oDate.disabled = true;
oYear.disabled = true;
}
else
{
oMonth.disabled = false;
oDate.disabled = false;
oYear.disabled = false;
}
}<body><input id="chkQ8Ongoing" type="checkbox" name="chkQ8Ongoing" onclick="Q8OngoingClicked(this)" /></body> Now, this works fine (tested with IE6 and FF1.0.6). However, I have added a subroutine that checks each of the responses to see if they are valid before it submits to our database. It states something like, "Question X had an invalid response. Please press your back button to make corrections and re-submit." As some of the gurus of the group can guess when I test the form and press the back button those items that were once disabled are now enabled even if the first item (chkQ8Ongoing in the example above) is checked.
So, I tried an ASP.NET (VB.NET Framework 1.1) approach where I have a function like:
Private Sub Page_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
If Me.IsPostBack Then
ReLoad()
End If
End Sub
....
Private Sub ReLoad()
If chkQ8Ongoing.Checked Then
lstQ8EndMonth.Enabled = False
...
Else
...
End If
End Sub
But this just ends up with an "Reference not set to an instance of an object" error condition. Then I went back to using StarupScript of JavaScript again like:
chkQ8Ongoing = document.getElementById('chkQ8Ongoing');
lstQ8EndMonth = document.getElementById('lstQ8EndMonth');
lstQ8EndDate = document.getElementById('lstQ8EndDate');
lstQ8EndYear = document.getElementById('lstQ8EndYear');
if (chkQ8Ongoing.checked)
{
lstQ8EndMonth.disabled = true;
lstQ8EndDate.disabled = true;
lstQ8EndYear.disabled = true;
}
else
{
lstQ8EndMonth.disabled = false;
lstQ8EndDate.disabled = false;
lstQ8EndYear.disabled = false;
}This works to disable items using Firefox but doesn't work in IE and I don't know why.
What am I missing?
Is there a way to do this purely in ASP.NET?
TIA...