Click to See Complete Forum and Search --> : Javascript Puzzle


eQuin0x
10-29-2003, 12:20 AM
Hi everyone,
having a problem with a script I'm trying to get to work atm
basically I have a complex form sorted into questions each question has a checkbox and upto 12 various input fields, and all I want to do is come up with a script that will disable the fields if the checkbox is unchecked and enabled when its checked .. I've been trying to work this out all day without any success so if anyone has any ideas or examples of how to do this it'd be great

Thanks in Advance
eQuin0x
:D

pelegk1
10-29-2003, 02:45 AM
use a js function

function onCheck(obj){
if (obj.checked==true){
//where i is the index value of the text field that should be the same as the number of the check box
document.all["text"+i].enabled=true;
}else{
document.all["text"+i].enabled=false;

}
}

eQuin0x
10-29-2003, 06:59 PM
ok I should have given a little more infomation what you have to sort of what I came up with but ... heres and example of what I'm doing ...



<TR>
<TD style="WIDTH: 16px; HEIGHT: 6px" bgColor="darkgray"><STRONG>1</STRONG></TD>
<TD style="WIDTH: 159px; HEIGHT: 6px"><STRONG>Window Set One</STRONG></TD>
<TD style="WIDTH: 4px; HEIGHT: 6px" bgColor="darkgray"><INPUT id="WindowSet1Inc" type="checkbox" runat="server"></TD>
<TD style="HEIGHT: 6px" width="50"><asp:dropdownlist id="WindowSetHeight1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="6">6</asp:ListItem>
<asp:ListItem Value="9">9</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="18">18</asp:ListItem>
<asp:ListItem Value="21">21</asp:ListItem>
</asp:dropdownlist></TD>
<TD style="HEIGHT: 6px" width="50"><asp:dropdownlist id="WindowSetWidth1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="6">6</asp:ListItem>
<asp:ListItem Value="9">9</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="18">18</asp:ListItem>
<asp:ListItem Value="21">21</asp:ListItem>
</asp:dropdownlist></TD>
<TD style="HEIGHT: 6px" width="20"><asp:textbox id="WindowsSetQuantity1" runat="server" BackColor="#C0FFFF" Width="30px"></asp:textbox></TD>
<TD style="HEIGHT: 6px" width="50"><asp:dropdownlist id="WindowSetGlazingBars1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No" Selected="True">No</asp:ListItem>
</asp:dropdownlist></TD>
<TD style="HEIGHT: 6px" width="50"><asp:dropdownlist id="WindowSetGreyTone1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No" Selected="True">No</asp:ListItem>
</asp:dropdownlist></TD>
<TD style="HEIGHT: 6px" width="50"><asp:dropdownlist id="WindowSetSteelLintel1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No" Selected="True">No</asp:ListItem>
</asp:dropdownlist></TD>
<TD style="HEIGHT: 6px" width="50"><asp:dropdownlist id="WindowSetSecurity1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No" Selected="True">No</asp:ListItem>
</asp:dropdownlist></TD>
<TD style="HEIGHT: 6px" width="50"><asp:dropdownlist id="WindowSetFlyScreens1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No" Selected="True">No</asp:ListItem>
</asp:dropdownlist></TD>
<TD style="HEIGHT: 6px" width="50">
<asp:DropDownList id="WindowSetVerticals1" runat="server" BackColor="LightBlue" Width="50px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No" Selected="True">No</asp:ListItem>
</asp:DropDownList></TD>
<TD style="HEIGHT: 6px" width="150">
<Color:ExtColorDropDownList id="WindowSetColour1" runat="server" Width="154px" xColorEnumName="BasicColors" xEmptyLabel="Select Colour" xColor="White" xColorBoxWidth="40px"></Color:ExtColorDropDownList></TD>
</TR>





as you can see all different types of inputs with totally different names and input strings.. so the above doesn't technically work unless a write a seperate function for every checkbox (there 30 question sets aprox / page)

pelegk1
11-08-2003, 07:38 AM
put this in a text fike