View Single Post
Old July 19th, 2006, 11:29 AM
carrie.mims carrie.mims is offline
Registered User
Join Date: Jul 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default enable/disable textfields based on radio selection

I've seen this post before, but I can't seem to tweak this code enough to fit the needs of the my form.

Here's what I'd like to accomplish:
-7 radio buttons and 4 text boxes that will enable or disable based on which radio button is selected.

-boxes to just be grayed out instead of disappearing

Here's what is accomplished:
The correct box will display with the correct button.
However, the "*make" box does not, should be next to the "*year" box.

Here's my code:
<script type="text/javascript">
function HideOrShowStuff(controlToHide)
    if (document.getElementById)
          document.getElementById('region1').style.display = 'none';
        document.getElementById('region2').style.display = 'none';
        document.getElementById('region3').style.display = 'none';

            ('region' + controlToHide).style.display = 'block';
            ('region' + controlToHide).disabled = '';
        alert('Sorry, your browser doesn\'t support this');


<form onsubmit="return checkrequired(this)" ENCTYPE="multipart/form-data" method="post" action="xxx">

<span class="template"> *Your Email </span><br />
<input name="requiredemail" type="text" class="formfield-data" id="email" size="40" />
<br /><br />

<span class="template"> *Dealer Name</span><br />
<input name="requireddealername" type="text" class="formfield-data" id="dealername" size="40" />
<br /><br />

<span class="template"> *Address</span> <span class="template2"> *Zip</span><br />
<input name="requiredaddress" type="text" class="formfield-data" id="address" size="40" maxlength="100" />
<input name="requiredzip" type="text" class="formfield2" id="zip" size="5" maxlength="5" />
<br /><br />

<span class="template">*Quanity</span><br />
<input name="requiredquanity" type="text" class="formfield-data" id="quanity" size="15" maxlength="15" />
<br /><br />

<span class="template">Selected Zip Codes (.xls)</span><br />
<input name="attachment" type="file" class="comments" id="Attachment" size="30" />
<br /><br />

<span class="template"> *List Type </span><img src="images/question.gif" style="padding-left:5px;" onclick="MM_openBrWindow('listdescription.html','' ,'width=375,height=500')"/><br />
<input class="formfield-data2" name="List" type="radio" value="Res Plus"/>Res Plus<br />
<input class="formfield-data2" name="List" type="radio" value="Consumer"/>Consumer<br />
<input class="formfield-data2" name="List" type="radio" value="RITAA" onclick="HideOrShowStuff(1)"/>RITAA<br />
<input class="formfield-data2" name="List" type="radio" value="Regular Auto" onclick="HideOrShowStuff(2)"/>Regular Auto<br />
<input class="formfield-data2" name="List" type="radio" value="Garage Predictor" onclick="HideOrShowStuff(2)"/>Garage Predictor<br />
<input class="formfield-data2" name="List" type="radio" value="True Credit" onclick="HideOrShowStuff(1)"/>True Credit<br />
<input class="formfield-data2" name="List" type="radio" value="True Credit w/ Tradelines" onclick="HideOrShowStuff(1)"/>True Credit w/ Tradelines<br />
<input class="formfield-data2" name="List" type="radio" value="Other" onclick="HideOrShowStuff(3)"/>Other
<br /><br />

<span class="template">*Range</span><br />
<input name="region1" id="region1" style="display:none;" type="text" class="formfield-data" size="15" maxlength="15" />
<br /><br />

<span class="template">*Year</span><span class="template">*Make</span><br />
<input name="region2" id="region2" style="display:none;" type="text" class="formfield-data" size="4" maxlength="4" /><input name="region2" id="region2" style="display:none;" type="text" class="formfield-data" size="15" maxlength="15" />
<br /><br />

<span class="template">*Other</span><br />
<input name="region3" id="region3" style="display:none;" type="text" class="formfield-data" size="40" maxlength="100" />
<br /><br />

<input name="submit" type="submit" class="comments" value="Submit" onclick="LimitAttach(this.form, this.form.attachment.value)"/>


Thanks, I'll appreciate any help :)