SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Hide/Unhide

  1. #1
    Froot r gewd SubKamran's Avatar
    Join Date
    May 2002
    Location
    North Star State
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide/Unhide

    What's wrong with this?

    First, when I select the value 'USA' it doesn't focus on it, and secondly when I pick 'HEHE' it wont reset the state to 'hidden'...everything else works...

    What i want it to do is show 'State' when the user selects 'USA' otherwise just keep it as is...but, if the user accidentally presses USA, and wants to go back to 'HEHE' then hide the 'State' again...

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title></title>
    <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <style type="text/css">
    	#state { visibility: hidden }
    </style>
    <script language="javascript">
    	function select() {
    		if (document.globe.country.selectedIndex='USA') {
    			state.style.visibility='visible';
    		}
    		else {
    			state.style.visibility='hidden';
    		}
    	}
    </script>
    
    </head>
    <body>
    <form name="globe" id="globe">
    <table width="500" align="center" border="0">
    	<tr>
    		<td>Country: <select name="country" id="country" onchange="select()">
    						<option value="" selected></option>
    						<option value="USA">USA</option>
    						<option value="HEHE">HEHE</option>
    					</select>
    		</td>
    	</tr>
    	<tr id="state">
    		<td>State: <select name="state">
    						<option value="MN">MN</option>
    						<option value="WI">WI</option>
    					</select>
    		</td>
    	</tr>
    </table>
    </form>
    </body>
    </html>
    "Sometimes little is more."
    Kamran A
    Web Dev/Designer
    Keyboard not found: Please Press F1 to Continue

  2. #2
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this...
    Code:
     
    <html>
    <head>
    <title></title>
    <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <style type="text/css">
    	#state { visibility: hidden }
    </style>
    <script language="javascript">
    	function select() {
    		if (document.getElementById("country").value=="USA") 
    			{state.style.visibility = "visible"}
    		else 
    			{state.style.visibility = "hidden"}
    	}
    </script>
    
    </head>
    <body>
    <form name="globe" id="globe">
    <table width="500" align="center" border="0">
    	<tr>
    		<td>Country: <select name="country" id="country" onchange="select()">
    						<option value="" selected></option>
    						<option value="USA">USA</option>
    						<option value="HEHE">HEHE</option>
    					</select>
    		</td>
    	</tr>
    	<tr id="state">
    		<td>State: <select name="state">
    						<option value="MN">MN</option>
    						<option value="WI">WI</option>
    					</select>
    		</td>
    	</tr>
    </table>
    </form>
    </body>
    </html>
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  3. #3
    Froot r gewd SubKamran's Avatar
    Join Date
    May 2002
    Location
    North Star State
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works like a dream. Thanks, now I know a new gizmo to use
    "Sometimes little is more."
    Kamran A
    Web Dev/Designer
    Keyboard not found: Please Press F1 to Continue

  4. #4
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    no probs
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •