Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide text box 1

Status
Not open for further replies.

TheCandyman

Technical User
Sep 9, 2002
761
US
I'm trying to have a row hidden when certain values are picked from a dropdown menu. The row seems to hide but still leaves the text box showing. I can't seem to figure out what I'm doing wrong that it won't hide the text box also.


Code:
<script type="text/javascript">
		function displayRow(temp,temp1,temp2){
		   var row = document.getElementById(temp1);
		   //alert(temp);
		   //alert(temp1);
		   //alert(temp2);
		   if (temp.selectedIndex==3||temp.selectedIndex==5) 
			    {row.style.display = 'none';
				 temp2.style.visibility='hidden';
			
				 }
		   else 
				{row.style.display = '';
				 temp2.style.visibility='visible';
				 }
		}
    </script>

Code:
<form action="step2.asp" method="post" name="form" onSubmit="return validateForm();" class="MyForm">
...
...
 <tr>
   <td><div align="right">Reg Category</div></td>
   <td><select name="x1_1" onchange="displayRow(this,'HidRow1','Number_1');" class="text">
           <option value="1">A</option>
           <option value="1">A</option>
           <option value="1">A</option>
           <option value="1">A</option>
           <option value="1">A</option>
           <option value="1">A</option>
       </select>
   </td>
 </tr>
 <tr>
    <td id="HidRow1" align="right">Membership Number</td>
    <td align="left"><input type="text" name="Number_1" maxlength="10" class="text" /></td>
 </tr>
...
...
 
I get an error of: "temp2.style is undefined", so that's the first thing I'd check.

Try using the full reference: document.forms['form'].elements[temp2].style.display=...



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
I put that code in and it that annoying text box is just sitting there smiling at me! Any other thoughts?

Code:
if (temp.selectedIndex==3||temp.selectedIndex==5) 
	{row.style.display = 'none';
	document.forms['form'].elements[temp2].style.display='hidden';
	}
else 
	{row.style.display = '';
	document.forms['form'].elements[temp2].style.display='visible';
	}
 
Really? It worked for me:
Code:
<script type="text/javascript">
        function displayRow(temp,temp1,temp2){
           var row = document.getElementById(temp1);
           //alert(temp);
           //alert(temp1);
           //alert(temp2);
           if (temp.selectedIndex==3||temp.selectedIndex==5)
                {row.style.display = 'none';
                 document.forms['form'].elements[temp2].style.visibility='hidden';
            
                 }
           else
                {row.style.display = '';
                 document.forms['form'].elements[temp2].style.visibility='visible';
                 }
        }
    </script>


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
I pulled this off the top of my page:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]

and it works great now. Thanks!
 
You should still be using a doctype. Try a regular HTML transitional instead of the XHTML

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top