473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to hid show divs using a radio button with js

1
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.    function showForm(x){
  3.     if (x == "professional") {
  4.          document.getElementById("form1").style.visibility='visible'; 
  5.          document.getElementById("form2").style.visibility='hidden'; 
  6.     }
  7.     else if (x == "distributor"){
  8.         document.getElementById("form2").style.visibility='visible'; 
  9.         document.getElementById("form1").style.visibility='hidden'; 
  10.     }
  11.    }
  12.  
  13. </script> <form>
  14.   Account Type: </br> <label><input  type="radio" name = "accountType" value="public" checked>  Public  </label> </br> <label><input  type="radio" id="professional" name = "accountType" onClick="showForm(this)" value="professional">  Professional </label> </br> <label> <input  type="radio" id="distributor" name = "accountType" onCLick="showForm(this)" value="distributor">  Distributor </label> </form> </br></br> <div id="form1">
  15.   Profession: 
  16.   <input type="text" name = "profession"> </br>
  17.    Company:  
  18.   <input type="text" name = "company"> </br>
  19.   Zip Code:   
  20.   <input type="text" name = "zipcode"> </br> </div> <div id="form2">
  21.    Company:  
  22.   <input type="text" name = "company"> </br>
  23.   Address: 
  24.   <input type="text" name = "address1"> </br>
  25.   Address: 
  26.   <input type="text" name = "address2"> </br>
  27.    City: 
  28.   <input type="text" name = "city"> </br>
  29.   State: 
  30.   <input type="text" name = "state"> </br>
  31.   Zip/Postal Code:   
  32.   <input type="text" name = "zipCode"> </br>
  33.    Country: 
  34.   <input type="text" name = "country"> </br> </div>
Dec 29 '14 #1
1 1467
Here, look at this:
http://jsfiddle.net/anox707h/

You might need to play with the css a bit, so you could position the lower form correctly.
Dec 30 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Don Grover | last post by:
I have a table thats wrapped in a div tag, that when user selects 1 of 2 radio buttons it hides or shows table, this works ok. But I want to set the table show hide on what the existing state of...
1
by: KatB | last post by:
I'm creating an asp.net page using VS.NET. TOPIC1 Radio button list TOPIC2 Radio button list etc.
10
by: Scuba Rob | last post by:
I am having problems on getting the radio button to work with my.settings correctly. I want the program to check to see which one was last saved to use at startup. The closest I have come is that I...
1
by: shror | last post by:
Hi every body, i want to know how i can use two radio buttons to turn on/off a midi file on my webpage, so that if the midi is running and i choose the off radio button then the midi is switched...
3
by: Milsnips | last post by:
hi there, i have a repeater which returns me a list of addresses in each repeaterItem row. at the end of each row i have a radiobutton, which i want the user to select the "active" address. ...
1
by: silviasalsa | last post by:
Hello cana someone help me. My goal is to have a set of radio buttons For example radiobutton1 radiobutton2 radiobutton3 radiobutton4 and a set of corresponding textboxes for example
1
by: hellogohel | last post by:
hi all, how do i display in detailview that is selected from gridview radiobutton? coding dynamically thanks in advance
1
by: rjlorenzo | last post by:
Good Day, I just need help on my programming. I would like to try to retrieved/edit the data i've save using radio button and want it to displayed on radio button for editing or changing the...
3
by: sree23 | last post by:
i am fetching records from mysql database am using while loop for displaying in side while loop am using radio button for each record am using ajax for posting each radio button value but it is not...
1
by: imtiyazrdl | last post by:
Hi I need customer can select delivery day name (Saturday and thus day ) using radio button and radio button is value store in order table or any new table and also mansion this day value in order...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.