Reply
Disabling Text fields when Radio Button is checked.
Old 07-24-2006, 03:47 PM Disabling Text fields when Radio Button is checked.
wacara's Avatar
Novice Talker

Posts: 14
Name: Wanda
Location: Belvidere, IL
This is my first post on Webmaster Talk and I truly hope someone can help me out.

I have a form with 2 checkboxes (should be radio buttons), 3 drop down menus and 1 text field. What I want to happen is when a user selects one of the 2 checkboxes, certain drop down fields and the text field will be enabled.

Currently I have two checkboxes for Analog & Digital but what I really need is Radio Buttons. I don't want the user to be able to select both. But I can't seem to get radio buttons to work.

I've been googling for 2 days now and trying lots of different ideas. It's been fun but they do not do what I need it to do. Especially when it comes to the radio buttons.

Does anyone have any Ideas?

Here's the javascript code that I am using:

Code:
<script language="javascript">
function enableAnalog() {
if (document.QRequest4a.transducer1.checked) 
    {
    document.QRequest4a.AnaOut.disabled = false;
    document.QRequest4a.DigOut.disabled = true;
    document.QRequest4a.pwm.disabled = true;
    document.QRequest4a.interrogation.disabled = true;
    } 
else 
    {
    document.QRequest4a.AnaOut.disabled = true;
    document.QRequest4a.DigOut.disabled = false;
    document.QRequest4a.pwm.disabled = false;
    document.QRequest4a.interrogation.disabled = false;
    }
}
function enableDigital() {    
if (document.QRequest4a.transducer2.checked) 
    {
    document.QRequest4a.AnaOut.disabled = true;
    document.QRequest4a.DigOut.disabled = false;
    document.QRequest4a.pwm.disabled = false;
    document.QRequest4a.interrogation.disabled = false;
    } 
else 
    {
    document.QRequest4a.AnaOut.disabled = false;
    document.QRequest4a.DigOut.disabled = true;
    document.QRequest4a.pwm.disabled = true;
    document.QRequest4a.interrogation.disabled = true;
    }
}
</script>
Here's my HTML code:

HTML Code:
<FORM action="QReqElecInfo.asp" method="post" name="QRequest4a" id="QRequest4a">
<table>
<tr>
<input name="Origin" type="hidden" id="Origin" value="true">
<td width="125"><strong>TRANSDUCER :</strong> 
                                    
<td width="395"><input name="transducer1" type="checkbox" value="Analog" onChange="enableAnalog();"> Analog
  <input name="transducer2" type="checkbox" value="Digital" onChange="enableDigital();">Digital</td>
</tr>
</table>
<p></p>
<table width="718">
<tr>
<td width="125" valign="bottom"><strong>ANALOG OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></TD>
                          <TD width="581" valign="bottom"><SELECT Name="AnaOut" disabled='disabled'>
                        <option value="Choose Type">Choose Output Type</option></select></td>
</tr>
</table>
<p></p>
<table width="713">
<tr>
<td width="128"><strong>DIGITAL OUTPUT <br> 
  SIGNAL TYPE :  &nbsp;&nbsp;</strong></td>
                          <td width="163"><SELECT Name="DigOut" disabled='disabled'>
                        <option value="Choose Type ">Choose Output Type</option>
                        </select></td>
<td width="444" valign="bottom"><strong>PWM OUTPUT:</strong>  <SELECT Name="pwm" disabled='disabled'>
                        <option value="Choose Type ">Choose Type</option>
                        </select></td>
</tr>
</table>
<p>&nbsp;</p>
<table width="806">
<tr>
<td width="143" valign="bottom"><strong>INTERROGATION:</strong></td>
<td width="313" valign="bottom">
  <SELECT Name="interrogation" disabled='disabled'>
                        <option value="Select One">Select One</option>
                        <option value="PULSE DURATION - INTERNAL INTERROGATION">PULSE DURATION - INTERNAL INTERROGATION</option>
                        <option value="PULSE DURATION - EXTERNAL INTERROGATION">PULSE DURATION - EXTERNAL INTERROGATION</option>
                        <option value="START/STOP PULSE">START/STOP PULSE</option>
        </select></td>
<td width="161" valign="bottom"><strong>RECIRCULATIONS:</strong></td>
<td width="576" valign="bottom"><INPUT Name="RECIRC" type="text" size="15" maxlength="15" disabled='disabled'>
</tr>
</table>
__________________
you gotta see it before you see it or you never will see it...
wacara is offline
Reply With Quote
View Public Profile Visit wacara's homepage!
 
When You Register, These Ads Go Away!
Old 07-24-2006, 07:56 PM Re: Disabling Text fields when Radio Button is checked.
funkdaddu's Avatar
Web Design Snob

Posts: 636
Here you go. Haven't tested it in IE, but it should work. I can explain anything if you need it:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
<script language="javascript"><!--
window.onload  = function() {
	analogSet = new Array(document.QRequest4a.AnaOut);
	digSet = new Array(document.QRequest4a.DigOut, document.QRequest4a.pwm, document.QRequest4a.interrogation);
	enabledSet = null;
	disabledSet = null;
}

function changeSet(obj) {
	if (obj.value == "Analog") {
		enabledSet = analogSet;
		disabledSet = digSet;
	} else if (obj.value == "Digital")  {
		enabledSet = digSet;
		disabledSet = analogSet;
	}
	for (x in enabledSet) {
		enabledSet[x].disabled = false;
	}
	for (y in disabledSet) {
		disabledSet[y].disabled = true;
	}
}
//-->
</script>	</head>

	<body bgcolor="#ffffff">
<FORM action="QReqElecInfo.asp" method="post" name="QRequest4a" id="QRequest4a">
<table>
<tr>
<input name="Origin" type="hidden" id="Origin" value="true">
<td width="125"><strong>TRANSDUCER :</strong> 
                                    
<td width="395"><input type="radio" name="transducer" value="Analog" onmouseup="changeSet(this);"> Analog
<input type="radio" name="transducer" value="Digital" onmouseup="changeSet(this);">Digital</td>
</tr>
</table>
<p></p>
<table width="718">
<tr>
<td width="125" valign="bottom"><strong>ANALOG OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></TD>
                          <TD width="581" valign="bottom"><SELECT Name="AnaOut" disabled='disabled'>
                        <option value="Choose Type">Choose Output Type</option></select></td>
</tr>
</table>
<p></p>
<table width="713">
<tr>
<td width="128"><strong>DIGITAL OUTPUT <br> 
  SIGNAL TYPE :  &nbsp;&nbsp;</strong></td>
                          <td width="163"><SELECT Name="DigOut" disabled='disabled'>
                        <option value="Choose Type ">Choose Output Type</option>
                        </select></td>
<td width="444" valign="bottom"><strong>PWM OUTPUT:</strong>  <SELECT Name="pwm" disabled='disabled'>
                        <option value="Choose Type ">Choose Type</option>
                        </select></td>
</tr>
</table>
<p>&nbsp;</p>
<table width="806">
<tr>
<td width="143" valign="bottom"><strong>INTERROGATION:</strong></td>
<td width="313" valign="bottom">
  <SELECT Name="interrogation" disabled='disabled'>
                        <option value="Select One">Select One</option>
                        <option value="PULSE DURATION - INTERNAL INTERROGATION">PULSE DURATION - INTERNAL INTERROGATION</option>
                        <option value="PULSE DURATION - EXTERNAL INTERROGATION">PULSE DURATION - EXTERNAL INTERROGATION</option>
                        <option value="START/STOP PULSE">START/STOP PULSE</option>
        </select></td>
<td width="161" valign="bottom"><strong>RECIRCULATIONS:</strong></td>
<td width="576" valign="bottom"><INPUT Name="RECIRC" type="text" size="15" maxlength="15" disabled='disabled'>
</tr>
</table>	</body>

</html>
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-24-2006, 10:17 PM Re: Disabling Text fields when Radio Button is checked.
wacara's Avatar
Novice Talker

Posts: 14
Name: Wanda
Location: Belvidere, IL
Thank you very much!! It worked perfectly. I even understood enough as to know where to put the text field so that it too would be enabled when I needed it to be. Thanks
__________________
you gotta see it before you see it or you never will see it...
wacara is offline
Reply With Quote
View Public Profile Visit wacara's homepage!
 
Old 07-25-2006, 02:19 PM Re: Disabling Text fields when Radio Button is checked.
wacara's Avatar
Novice Talker

Posts: 14
Name: Wanda
Location: Belvidere, IL
I came into work today, ready to jump into more coding. Then they added more requirements to what they wanted on the first part.

Can you help me in getting the drop down menu items to also enable a set of fields when selected. Each item on the menu has a different set of fields to enable.

I tried using the format that you used creating an array of each set of fields, but that did not work. I might be on the right track but missing something vitally important. Or I could be way off base.

Here's the code I tried to make work...what did I do wrong?

Code:
window.onload  = function() {
    analogSet = new Array(document.QRequest4a.AnaOut);
    digSet = new Array(document.QRequest4a.DigOut, document.QRequest4a.pwm);
    digOutSet1 = new Array (document.QRequest4a.interrogation, document.QRequest4a.recirc);
    digOutSet2 = new Array (document.QRequest4a.format, document.QRequest4a.resolution, document.QRequest4a.performance, document.QRequest4a.opts);
    digOutSet3 = new Array (document.QRequest4a.protocol);
    enabledSet = null;
    disabledSet = null;
}

function changeSet(obj) {
    if (obj.value == "Analog") {
        enabledSet = analogSet;
        disabledSet = digSet;
    } else if (obj.value == "Digital")  {
        enabledSet = digSet;
        disabledSet = analogSet;
    } else if(obj.value == "PWM") {
        enabledSet = digOutSet1;
        disabledSet = digOutSet2; digOutSet3;
    } else if (obj.value == "SSI") {
        enabledSet = digOutSet2;
        disabledSet = digOutSet1; digOutSet3;
    } else if (obj.value == "CAN_BUS") {
        enabledSet = digOutSet3;
        disabledSet = digOutSet1; digOutSet2;
    }
    for (x in enabledSet) {
        enabledSet[x].disabled = false;
    }
    for (y in disabledSet) {
        disabledSet[y].disabled = true;
    }
}
HTML Code:
<td width="134"><strong>DIGITAL OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></td>
<td width="255">        <SELECT Name="DigOut" onchange="changeSet(this)" disabled='disabled'>
                        <option value="Choose Type ">CHOOSE OUTPUT TYPE</option>
                        <option value="PWM " onchange="changeSet(this)">PWM</option>
                        <option value="SSI " >SSI</option>
                        <option value="CAN_BUS ">CAN BUS</option>
                        <option value="START/STOP ">START/STOP</option>
                        </select></td>
</tr>
</table>
__________________
you gotta see it before you see it or you never will see it...
wacara is offline
Reply With Quote
View Public Profile Visit wacara's homepage!
 
Old 07-25-2006, 02:26 PM Re: Disabling Text fields when Radio Button is checked.
wacara's Avatar
Novice Talker

Posts: 14
Name: Wanda
Location: Belvidere, IL
They've added more requirements as to what they want this form to do.

Can you help me in getting the drop down menu items to also enable a set of fields when selected. Each item on the menu has a different set of fields to enable.

I tried using the format that you used creating an array of each set of fields, but that did not work. I might be on the right track but missing something vitally important. Or I could be way off base.

Here's the code I tried to make work...what did I do wrong?


Code:
window.onload  = function() {
    analogSet = new Array(document.QRequest4a.AnaOut);
    digSet = new Array(document.QRequest4a.DigOut, document.QRequest4a.pwm);
    digOutSet1 = new Array (document.QRequest4a.interrogation, document.QRequest4a.recirc);
    digOutSet2 = new Array (document.QRequest4a.format, document.QRequest4a.resolution, document.QRequest4a.performance, document.QRequest4a.opts);
    digOutSet3 = new Array (document.QRequest4a.protocol);
    enabledSet = null;
    disabledSet = null;
}

function changeSet(obj) {
    if (obj.value == "Analog") {
        enabledSet = analogSet;
        disabledSet = digSet;
    } else if (obj.value == "Digital")  {
        enabledSet = digSet;
        disabledSet = analogSet;
    } else if(obj.value == "PWM") {
        enabledSet = digOutSet1;
        disabledSet = digOutSet2; digOutSet3;
    } else if (obj.value == "SSI") {
        enabledSet = digOutSet2;
        disabledSet = digOutSet1; digOutSet3;
    } else if (obj.value == "CAN_BUS") {
        enabledSet = digOutSet3;
        disabledSet = digOutSet1; digOutSet2;
    }
    for (x in enabledSet) {
        enabledSet[x].disabled = false;
    }
    for (y in disabledSet) {
        disabledSet[y].disabled = true;
    }
}


HTML Code:
<td width="134"><strong>DIGITAL OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></td>
<td width="255">        <SELECT Name="DigOut" onchange="changeSet(this)" disabled='disabled'>
                        <option value="Choose Type ">CHOOSE OUTPUT TYPE</option>
                        <option value="PWM " onchange="changeSet(this)">PWM</option>
                        <option value="SSI " >SSI</option>
                        <option value="CAN_BUS ">CAN BUS</option>
                        <option value="START/STOP ">START/STOP</option>
                        </select></td>
</tr>
</table>


__________________
Quote:
Originally Posted by funkdaddu View Post
Here you go. Haven't tested it in IE, but it should work. I can explain anything if you need it:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>

    <head>
        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
        <title>Untitled Page</title>
<script language="javascript"><!--
window.onload  = function() {
    analogSet = new Array(document.QRequest4a.AnaOut);
    digSet = new Array(document.QRequest4a.DigOut, document.QRequest4a.pwm, document.QRequest4a.interrogation);
    enabledSet = null;
    disabledSet = null;
}

function changeSet(obj) {
    if (obj.value == "Analog") {
        enabledSet = analogSet;
        disabledSet = digSet;
    } else if (obj.value == "Digital")  {
        enabledSet = digSet;
        disabledSet = analogSet;
    }
    for (x in enabledSet) {
        enabledSet[x].disabled = false;
    }
    for (y in disabledSet) {
        disabledSet[y].disabled = true;
    }
}
//-->
</script>    </head>

    <body bgcolor="#ffffff">
<FORM action="QReqElecInfo.asp" method="post" name="QRequest4a" id="QRequest4a">
<table>
<tr>
<input name="Origin" type="hidden" id="Origin" value="true">
<td width="125"><strong>TRANSDUCER :</strong> 
                                    
<td width="395"><input type="radio" name="transducer" value="Analog" onmouseup="changeSet(this);"> Analog
<input type="radio" name="transducer" value="Digital" onmouseup="changeSet(this);">Digital</td>
</tr>
</table>
<p></p>
<table width="718">
<tr>
<td width="125" valign="bottom"><strong>ANALOG OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></TD>
                          <TD width="581" valign="bottom"><SELECT Name="AnaOut" disabled='disabled'>
                        <option value="Choose Type">Choose Output Type</option></select></td>
</tr>
</table>
<p></p>
<table width="713">
<tr>
<td width="128"><strong>DIGITAL OUTPUT <br> 
  SIGNAL TYPE :  &nbsp;&nbsp;</strong></td>
                          <td width="163"><SELECT Name="DigOut" disabled='disabled'>
                        <option value="Choose Type ">Choose Output Type</option>
                        </select></td>
<td width="444" valign="bottom"><strong>PWM OUTPUT:</strong>  <SELECT Name="pwm" disabled='disabled'>
                        <option value="Choose Type ">Choose Type</option>
                        </select></td>
</tr>
</table>
<p>&nbsp;</p>
<table width="806">
<tr>
<td width="143" valign="bottom"><strong>INTERROGATION:</strong></td>
<td width="313" valign="bottom">
  <SELECT Name="interrogation" disabled='disabled'>
                        <option value="Select One">Select One</option>
                        <option value="PULSE DURATION - INTERNAL INTERROGATION">PULSE DURATION - INTERNAL INTERROGATION</option>
                        <option value="PULSE DURATION - EXTERNAL INTERROGATION">PULSE DURATION - EXTERNAL INTERROGATION</option>
                        <option value="START/STOP PULSE">START/STOP PULSE</option>
        </select></td>
<td width="161" valign="bottom"><strong>RECIRCULATIONS:</strong></td>
<td width="576" valign="bottom"><INPUT Name="RECIRC" type="text" size="15" maxlength="15" disabled='disabled'>
</tr>
</table>    </body>

</html>
__________________
you gotta see it before you see it or you never will see it...
wacara is offline
Reply With Quote
View Public Profile Visit wacara's homepage!
 
Old 07-25-2006, 07:53 PM Re: Disabling Text fields when Radio Button is checked.
funkdaddu's Avatar
Web Design Snob

Posts: 636
Code:
        disabledSet = digOutSet1; digOutSet2;
This will do nothing you're just listing a variable, it's notdoing anything with it... you need to join the 2 arrays:
Code:
disabledSet = digOutSet1;
disabledSet.concat(digOutSet2);
and instead of all the else if, else if, try using switch:

http://www.w3schools.com/js/js_switch.asp
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-28-2006, 07:56 AM Re: Disabling Text fields when Radio Button is checked.
wacara's Avatar
Novice Talker

Posts: 14
Name: Wanda
Location: Belvidere, IL
Quote:
Originally Posted by funkdaddu View Post
Code:
        disabledSet = digOutSet1; digOutSet2;
This will do nothing you're just listing a variable, it's notdoing anything with it... you need to join the 2 arrays:
Code:
disabledSet = digOutSet1;
disabledSet.concat(digOutSet2);
and instead of all the else if, else if, try using switch:

JavaScript Switch Statement
I'm still having problems...please check my code and tell me what I'm doing wrong Any help is greatly appreciated. I haven't put all of in there...I've been trying it piece by piece. If I could get one to work then I'd be able to get the other pieces to work.

Code:
<script language="javascript">
window.onload  = function() {
    analogSet = new Array(document.QRequest4a.AnaOut);
    digSet = new Array(document.QRequest4a.DigOut, document.QRequest4a.pwm);
    digOutSet1 = new Array (document.QRequest4a.interrogation, document.QRequest4a.recirc);
    digOutSet2 = new Array (document.QRequest4a.format, document.QRequest4a.resolution, document.QRequest4a.performance, document.QRequest4a.opts);
    digOutSet3 = new Array (document.QRequest4a.protocol);
    switchACSet = new Array (document.QRequest4a.SwitchLoc);
    switchDCSet = new Array (document.QRequest4a.connector, document.QRequest4a.electronP, document.QRequest4a.electronN);
    enabledSet = null;
    disabledSet = null;
    var Analog = analogSet;
    
    }
switch (obj) {
    case obj.value == "Analog":
        enabledSet = analogSet;
        disabledSet = digSet;
        break;
    case obj.value == "Digital":
        enabledSet = digSet;
        disabledSet = analogSet;
        break;
    case obj.value == "AC":
        enabledSet = switchACSet;
        disabledSet = switchDCSet;
        break;
    case obj.value == "DC":
        enabledSet = switchDCSet;
        disabledSet = switchACSet;
        break;
}
for (x in enabledSet) {
    enabledSet[x].disbled = false;
}
for (y in disabledSet) {
    disabledSet[y].disabled = true;
}


</script>

</head>

<body>
<div align="center"><STRONG>QUOTE REQUEST<BR>
<font size="+1"><EM>ELECTRONICS INFORMATION</EM></font></STRONG></div>
<P>&nbsp;</P>
<FORM action="QReqElecInfo.asp" method="post" name="QRequest4a" id="QRequest4a">
<table>
<tr>
<input name="Origin" type="hidden" id="Origin" value="true">
<td width="125"><strong>TRANSDUCER :</strong> 
                                    
<td width="395"><input type="radio" name="transducer" value="Analog" onmouseup="changeSet(this);"> Analog
<input type="radio" name="transducer" value="Digital" onmouseup="changeSet(this);">Digital</td>
</tr>
</table>
<p></p>
<table width="863">
<tr>
<td width="141" valign="bottom"><strong>ANALOG OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></TD>
<TD width="313" valign="bottom"><SELECT Name="AnaOut" disabled='disabled'>
                        <option value="Choose Type">Choose Output Type</option>
                        <option value="0 to +10 VDC">0 to +10 VDC</option>
                        <option value="+10 to 0 VDC">+10 to 0 VDC</option>
                        <option value="-10 to +10 VDC">-10 to +10 VDC</option>
                        <option value="+10 to -10 VDC">+10 to -10 VDC</option>
                        <option value="4 to 20 MA">4 to 20 MA</option>
                        <option value="20 TO 4 MA">20 TO 4 MA</option>
                        <option value="0 to 20 MA">0 to 20 MA</option>
                        <option value="20 to 0 MA">20 to 0 MA</option>
                        <option value="OTHER">OTHER</option>
                        </select></td>
                        
<td width="134"><strong>DIGITAL OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></td>
<td width="255">        <SELECT Name="DigOut" id="DigOut" disabled='disabled'>
                        <option value="Choose Type ">CHOOSE OUTPUT TYPE</option>
                        <option value="PWM ">PWM</option>
                        <option value="SSI ">SSI</option>
                        <option value="CAN_BUS ">CAN BUS</option>
                        <option value="START/STOP ">START/STOP</option>
                        </select></td>
</tr>
</table>
<p></p>
<table width="806">
<tr>
<td width="143" valign="bottom"><strong>INTERROGATION:</strong></td>
<td width="313" valign="bottom">
                          <SELECT Name="interrogation" disabled='disabled'>
                        <option value="Select One">Select One</option>
                        <option value="PULSE DURATION - INTERNAL INTERROGATION">PULSE DURATION - INTERNAL INTERROGATION</option>
                        <option value="PULSE DURATION - EXTERNAL INTERROGATION">PULSE DURATION - EXTERNAL INTERROGATION</option>
                        <option value="START/STOP PULSE">START/STOP PULSE</option>
                        </select></td>
<td width="161" valign="bottom"><strong>RECIRCULATIONS:</strong></td>
<td width="576" valign="bottom"><INPUT Name="recirc" type="text" size="25" maxlength="25" disabled='disabled'>
</tr>
<TR>
</table>
<p></p>
<table>
<td width="161" valign="bottom"><strong>DATA LENGTH:</strong></td>
<td width="161" valign="bottom"><strong>Format:</strong></td>
<td width="576" valign="bottom"><INPUT Name="format" type="text" size="25" maxlength="25" disabled='disabled'>
<td width="161" valign="bottom"><strong>Resolution:</strong></td>
<td width="576" valign="bottom"><INPUT Name="resolution" type="text" size="25" maxlength="25" disabled='disabled'>
<td width="161" valign="bottom"><strong>Performance:</strong></td>
<td width="576" valign="bottom"><INPUT Name="performance" type="text" size="25" maxlength="25" disabled='disabled'>
<td width="161" valign="bottom"><strong>Options:</strong></td>
<td width="576" valign="bottom"><INPUT Name="opts" type="text" size="25" maxlength="25" disabled='disabled'>
</TR>
</table>
<p></p>
<table>
<tr>
<td width="95" valign="bottom"><strong>PROTOCOL:</strong></td>
<td width="537" valign="bottom">
                          <SELECT Name="protocol" disabled='disabled'>
                        <option value="Select One">Select One</option>
                        <option value="device_net">DEVICE NET</option>
                        <option value="can_basic">CAN BASIC</option>
                        <option value="can_open">CAN OPEN</option>
                        </select></td>
</tr>
</table>
<P></P>
<P></P>
<P></P>
<table height="31">
  <TR><td>**********************************************************************************</td></TR></table>
<p></p>
<p></p>
<p></p>
<table>
<tr>
<td width="104"><strong>SWITCHES:</strong></td>
<td width="225"><input name="switches" type="radio" value="AC" onmouseup="changeSet(this);">AC
                  <input name="switches" type="radio" value="DC" onmouseup="changeSet(this);">DC</td>

</tr>
</table>
<p></p>
<table width="1034">
<tr>
<td width="79" valign="bottom">SWITCH <BR> LOCATION</td>
<td width="120"><input name="SwitchLoc" type="text" size="20" maxlength="20" disabled='disabled'></td>
<td width="103" valign="bottom">CONNECTOR <BR> ORIENTATION</td>
<td width="184"><input name="connector" type="text" size="20" maxlength="20" disabled='disabled'></td>
<td width="524"><input name="electronP" type="checkbox" value="PNP" disabled='disabled'>PNP 
                <input name="electronN" type="checkbox" value="NPN" disabled='disabled'>NPN</td>
</tr>
</table>
__________________
you gotta see it before you see it or you never will see it...
wacara is offline
Reply With Quote
View Public Profile Visit wacara's homepage!
 
Old 07-28-2006, 05:42 PM Re: Disabling Text fields when Radio Button is checked.
funkdaddu's Avatar
Web Design Snob

Posts: 636
1) switch is like if/else - you still need the function we created, and the switch statements can't use operators (x==y,x>y) it's just a comparison (here is x, does x match y? does x match z?). Take a look how it's done:
Code:
window.onload  = function() {
    analogSet = new Array(document.QRequest4a.AnaOut);
    digSet = new Array(document.QRequest4a.DigOut, document.QRequest4a.pwm);
    digOutSet1 = new Array (document.QRequest4a.interrogation, document.QRequest4a.recirc);
    digOutSet2 = new Array (document.QRequest4a.format, document.QRequest4a.resolution, document.QRequest4a.performance, document.QRequest4a.opts);
    digOutSet3 = new Array (document.QRequest4a.protocol);
    switchACSet = new Array (document.QRequest4a.SwitchLoc);
    switchDCSet = new Array (document.QRequest4a.connector, document.QRequest4a.electronP, document.QRequest4a.electronN);
    enabledSet = null;
    disabledSet = null;
    var Analog = analogSet;
    
}

function changeSet(obj) {
	switch (obj.value) {
	    case "Analog":
	        enabledSet = analogSet;
	        disabledSet = digSet;
	        break;
	    case "Digital":
	        enabledSet = digSet;
	        disabledSet = analogSet;
	        break;
	    case "AC":
	        enabledSet = switchACSet;
	        disabledSet = switchDCSet;
	        break;
	    case "DC":
	        enabledSet = switchDCSet;
	        disabledSet = switchACSet;
	        break;
	}
	for (x in enabledSet) {
	    enabledSet[x].disabled = false;
	}
	for (y in disabledSet) {
	    disabledSet[y].disabled = true;
	}
}
This should get the script working again, but I don't know if it's doing what you want it to.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-30-2006, 11:52 AM Re: Disabling Text fields when Radio Button is checked.
wacara's Avatar
Novice Talker

Posts: 14
Name: Wanda
Location: Belvidere, IL
Thanks for getting the script working again and I do understand what had to be done and what I did wrong.

But you are correct...It's doing what I started out needing it to do but now I need it to do more. Hopefully, I can explain what I'm trying to do. I've attached all the code so you can get a better look at how this should work.

1. on the dropdown menu when the user selects an option, I need one set of options to be enabled while the other 3 sets remain disabled.

ex. after the user chooses "Digital", then the drop down menu is enabled. If they select PWM from the menu, then I want "digOutSet1" to become enabled which is what I can't figure how to make happen.

Hopefully, that is a better explanation of what I am trying to do and that supplying all the code helps you to better understand.


Code:
<%@LANGUAGE="VBSCRIPT"%>
<% option explicit
Response.Expires = -1
Server.ScriptTimeout = 600

 Dim MailBody 
    '=======================================
    '              QReqMtgInfo
    '=======================================
%>


<%
'...................................................................................................................................
    ' VARIABLE DEFINITIONS
    Dim objConn, objComm, strSQL, strConnectionString
    ' CONSTANTS
    const adVarChar        = 200
    const adChar        = 129
    const adParamInput    = 1
'*************************************************************************************************************************************************

'*************************************************************************************************************************************************
' SET THE CONNECTION STRING
    strConnectionString = "DSN=CylinderDSN;UID=CylinderUser;Pwd=cylinderdiv"
    'strConnectionString = "DSN=QuotePortal;UID=wrattliffe;Pwd=carratt"
    'strConnectionString = "DSN=CYLTEST;UID=CylinderUser;Pwd=cylinderdiv"
    'strConnectionString = "Provider=SQLOLEDB;Data Source"COR089XD13\TEST0";Initial Catalog=QuotePortal;User ID='wrattliffe';Password='carratt';"

'**************************************************************************************************************************************************
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">-->
<title>Mounting Info</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #000066;
}
body {
    background-color: #FFFFFF;
}
-->
</style>
<script language="javascript">
window.onload  = function() {
    analogSet = new Array(document.QRequest4a.AnaOut);
    digSet = new Array(document.QRequest4a.DigOut, document.QRequest4a.pwm);
    digOutSet1 = new Array (document.QRequest4a.interrogation, document.QRequest4a.recirc);
    digOutSet2 = new Array (document.QRequest4a.format, document.QRequest4a.resolution, document.QRequest4a.performance, document.QRequest4a.opts);
    digOutSet3 = new Array (document.QRequest4a.protocol);
    switchACSet = new Array (document.QRequest4a.SwitchLoc);
    switchDCSet = new Array (document.QRequest4a.connector, document.QRequest4a.electronP, document.QRequest4a.electronN);
    enabledSet = null;
    disabledSet = null;
    var Analog = analogSet;
    
    }
function changeSet(obj) {
    switch (obj.value) {
        case "Analog":
            enabledSet = analogSet;
            disabledSet = digSet;
            break;
        case "Digital":
            enabledSet = digSet;
            disabledSet = analogSet;
            break;
        case "AC":
            enabledSet = switchACSet;
            disabledSet = switchDCSet;
            break;
        case "DC":
            enabledSet = switchDCSet;
            disabledSet = switchACSet;
            break;
    }
    for (x in enabledSet) {
        enabledSet[x].disabled = false;
    }
    for (y in disabledSet) {
        disabledSet[y].disabled = true;
    }
}

</script>

</head>

<body>
<div align="center"><STRONG>QUOTE REQUEST<BR>
<font size="+1"><EM>ELECTRONICS INFORMATION</EM></font></STRONG></div>
<P>&nbsp;</P>
<FORM action="QReqElecInfo.asp" method="post" name="QRequest4a" id="QRequest4a">
<table>
<tr>
<input name="Origin" type="hidden" id="Origin" value="true">
<td width="125"><strong>TRANSDUCER :</strong> 
                                    
<td width="395"><input type="radio" name="transducer" value="Analog" onmouseup="changeSet(this);"> Analog
<input type="radio" name="transducer" value="Digital" onmouseup="changeSet(this);">Digital</td>
</tr>
</table>
<p></p>
<table width="863">
<tr>
<td width="141" valign="bottom"><strong>ANALOG OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></TD>
<TD width="313" valign="bottom"><SELECT Name="AnaOut" disabled='disabled'>
                        <option value="Choose Type">Choose Output Type</option>
                        <option value="0 to +10 VDC">0 to +10 VDC</option>
                        <option value="+10 to 0 VDC">+10 to 0 VDC</option>
                        <option value="-10 to +10 VDC">-10 to +10 VDC</option>
                        <option value="+10 to -10 VDC">+10 to -10 VDC</option>
                        <option value="4 to 20 MA">4 to 20 MA</option>
                        <option value="20 TO 4 MA">20 TO 4 MA</option>
                        <option value="0 to 20 MA">0 to 20 MA</option>
                        <option value="20 to 0 MA">20 to 0 MA</option>
                        <option value="OTHER">OTHER</option>
                        </select></td>
                        
<td width="134"><strong>DIGITAL OUTPUT <br> SIGNAL TYPE :  &nbsp;&nbsp;</strong></td>
<td width="255">        <SELECT Name="DigOut" id="DigOut" disabled='disabled'>
                        <option value="Choose Type ">CHOOSE OUTPUT TYPE</option>
                        <option value="PWM ">PWM</option>
                        <option value="SSI ">SSI</option>
                        <option value="CAN_BUS ">CAN BUS</option>
                        <option value="START/STOP ">START/STOP</option>
                        </select></td>
</tr>
</table>
<p></p>
<table width="806">
<tr>
<td width="143" valign="bottom"><strong>INTERROGATION:</strong></td>
<td width="313" valign="bottom">
                          <SELECT Name="interrogation" disabled='disabled'>
                        <option value="Select One">Select One</option>
                        <option value="PULSE DURATION - INTERNAL INTERROGATION">PULSE DURATION - INTERNAL INTERROGATION</option>
                        <option value="PULSE DURATION - EXTERNAL INTERROGATION">PULSE DURATION - EXTERNAL INTERROGATION</option>
                        <option value="START/STOP PULSE">START/STOP PULSE</option>
                        </select></td>
<td width="161" valign="bottom"><strong>RECIRCULATIONS:</strong></td>
<td width="576" valign="bottom"><INPUT Name="recirc" type="text" size="25" maxlength="25" disabled='disabled'>
</tr>
<TR>
</table>
<p></p>
<table>
<td width="161" valign="bottom"><strong>DATA LENGTH:</strong></td>
<td width="161" valign="bottom"><strong>Format:</strong></td>
<td width="576" valign="bottom"><INPUT Name="format" type="text" size="25" maxlength="25" disabled='disabled'>
<td width="161" valign="bottom"><strong>Resolution:</strong></td>
<td width="576" valign="bottom"><INPUT Name="resolution" type="text" size="25" maxlength="25" disabled='disabled'>
<td width="161" valign="bottom"><strong>Performance:</strong></td>
<td width="576" valign="bottom"><INPUT Name="performance" type="text" size="25" maxlength="25" disabled='disabled'>
<td width="161" valign="bottom"><strong>Options:</strong></td>
<td width="576" valign="bottom"><INPUT Name="opts" type="text" size="25" maxlength="25" disabled='disabled'>
</TR>
</table>
<p></p>
<table>
<tr>
<td width="95" valign="bottom"><strong>PROTOCOL:</strong></td>
<td width="537" valign="bottom">
                          <SELECT Name="protocol" disabled='disabled'>
                        <option value="Select One">Select One</option>
                        <o