Click here to Skip to main content
16,011,538 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: What do mean by RSS feed? Pin
Sathesh Sakthivel6-Nov-06 19:49
Sathesh Sakthivel6-Nov-06 19:49 
Questionhi i got problem with php Pin
Arif Liminto6-Nov-06 18:46
professionalArif Liminto6-Nov-06 18:46 
AnswerRe: hi i got problem with php Pin
CWIZO6-Nov-06 20:54
CWIZO6-Nov-06 20:54 
GeneralRe: hi i got problem with php Pin
Arif Liminto7-Nov-06 2:47
professionalArif Liminto7-Nov-06 2:47 
GeneralRe: hi i got problem with php Pin
CWIZO7-Nov-06 2:55
CWIZO7-Nov-06 2:55 
GeneralRe: hi i got problem with php Pin
Arif Liminto7-Nov-06 4:25
professionalArif Liminto7-Nov-06 4:25 
GeneralRe: hi i got problem with php Pin
CWIZO7-Nov-06 5:46
CWIZO7-Nov-06 5:46 
QuestionJavascript - DropList Selection [modified] - SOLVED! Pin
#realJSOP6-Nov-06 9:50
professional#realJSOP6-Nov-06 9:50 
Working in asp.net 2.0/C#

I have a form in my webpage.aspx file that implements a droplist control. The form looks like this:

<form id="formEmpSurvey" runat="server">
<center>
<br />
<table style="width:680px;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 187px; height: 26px;" align="left">
<asp:CheckBox ID="checkSymptomCough" runat="server" Text="Persistent cough" Enabled="True" />
</td>
<td style="width: 250px; height: 26px;" align="right">
<asp:Label ID="labelDurationCough" runat="server" Text="Duration" Enabled="False"></asp:Label>
<asp:DropDownList ID="comboDurationCough" runat="server" Enabled="False">
<asp:ListItem Value="0">Choose One...</asp:ListItem>
<asp:ListItem Value="1">Less than one month</asp:ListItem>
<asp:ListItem Value="2">1 month</asp:ListItem>
<asp:ListItem Value="3">2 months</asp:ListItem>
<asp:ListItem Value="4">3 months</asp:ListItem>
<asp:ListItem Value="5">4 months</asp:ListItem>
<asp:ListItem Value="6">5 months</asp:ListItem>
<asp:ListItem Value="7">6 months</asp:ListItem>
<asp:ListItem Value="8">More than 6 months</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>


Next, I have javascript that looks like this:

//------------------------------------------------------------------------------
function disableLabel(lbl, disable)
{
lbl.obj.disabled = disable;
}

//------------------------------------------------------------------------------
function disableCombo(combo, disable)
{
combo.obj.disabled = disable;
}

//------------------------------------------------------------------------------
function resetCombo(combo)
{
combo.selectedIndex = 0;
}

//------------------------------------------------------------------------------
function checkChanged(name)
{
var check = new getObj("checkSymptom" + name);
var label = new getObj("labelDuration" + name);
var combo = new getObj("comboDuration" + name);

// if the checkbox is checked, enable the duration lable/combobox pair
if (check.obj.checked == true)
{
disableLabel(label, false);
disableCombo(combo, false);
}
else
{
// otherwise, reset the combo selection and disable them
resetCombo(combo);
disableLabel(label, true);
disableCombo(combo, true);
}
}

//------------------------------------------------------------------------------
function checkCoughChanged()
{
checkChanged("Cough");
}


Finally, in the aspx.cs Page_Load function, I have this:

protected void Page_Load(object sender, EventArgs e)
{
checkSymptomCough.Attributes.Add("onclick", "checkCoughChanged();");
}

====================================

As you can see, the label and droplist start out in a disabled state. When I check the checkbox, the form correctly enables the label and the droplist controls.

When I un-check the checkbox, the desired result is that the label and droplist become disabled, and the droplist set to the 0'th index ("Select One...").

However, when I un-check the checkbox, the label and droplist are correctly disabled, but the selection in the droplist doesn't change.

IE reports no javascript errors at all.

What am I doing wrong?



"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997-----"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001



-- modified at 12:26 Tuesday 7th November, 2006
AnswerRe: Javascript - DropList Selection Pin
Steve Echols6-Nov-06 18:58
Steve Echols6-Nov-06 18:58 
GeneralRe: Javascript - DropList Selection Pin
#realJSOP7-Nov-06 3:35
professional#realJSOP7-Nov-06 3:35 
GeneralRe: Javascript - DropList Selection Pin
#realJSOP7-Nov-06 6:26
professional#realJSOP7-Nov-06 6:26 
GeneralRe: Javascript - DropList Selection Pin
Steve Echols7-Nov-06 7:07
Steve Echols7-Nov-06 7:07 
QuestionBack Button Problem Pin
RockyGuls6-Nov-06 8:59
RockyGuls6-Nov-06 8:59 
AnswerRe: Back Button Problem Pin
g00fyman6-Nov-06 11:50
g00fyman6-Nov-06 11:50 
QuestionSelect All - From Likst Box Pin
RockyGuls6-Nov-06 8:14
RockyGuls6-Nov-06 8:14 
QuestionIE 7: can't get rid of URL bar using window.open Pin
MrBink6-Nov-06 7:57
MrBink6-Nov-06 7:57 
AnswerRe: IE 7: can't get rid of URL bar using window.open Pin
Guffa6-Nov-06 9:19
Guffa6-Nov-06 9:19 
GeneralRe: IE 7: can't get rid of URL bar using window.open Pin
MrBink6-Nov-06 10:40
MrBink6-Nov-06 10:40 
QuestionSeparate Application Pools Pin
happyheartcs6-Nov-06 2:58
happyheartcs6-Nov-06 2:58 
AnswerRe: Separate Application Pools Pin
Guffa6-Nov-06 9:38
Guffa6-Nov-06 9:38 
Questionattachments in outlook Pin
YaronNir6-Nov-06 2:49
YaronNir6-Nov-06 2:49 
QuestionEnding Session in asp vbscript Pin
krishna196-Nov-06 2:34
krishna196-Nov-06 2:34 
AnswerRe: Ending Session in asp vbscript Pin
jmendham6-Nov-06 9:34
jmendham6-Nov-06 9:34 
QuestionMoving DataGrid Item to Text Box Pin
meeram3955-Nov-06 22:45
meeram3955-Nov-06 22:45 
QuestionFree html templates with flash Pin
samerh5-Nov-06 20:47
samerh5-Nov-06 20:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.