473,655 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to hid show divs using a radio button with js

1 New Member
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 1474
Horadrim
1 New Member
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
11923
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 radio buttons are on page load aswell, so if one button is allready selected then the table is hidden else it is shown, can some help me with this, Existing code below Regards Don. '**************** <html>
1
2005
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
2615
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 need to click the radio button twice for it to be saved correctly. Any idea on what to use? I think the code should be fairly simple but I am missing it for some reason.
1
1919
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 off instantly without any loading. is that possible or not, and if possible please tell me how to do it. Thanks shror www.s7els7.com
3
8237
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. However when i try selecting a radiobutton it does not deselect the others in the repeater. I tried adding a "GroupName" property but it still doesnt work.
1
1360
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
5023
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
2318
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 choices. For example i have 2 radio buttone voice and data. when is save on the database the value of checked button is "1". Then when the use want to change their choices I want to display this radio button that the one with check is the one with...
3
5800
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 working properly sql query is <?php //db connection $query1=mysql_query("select * from questions "); while($res1=mysql_fetch_array($query1)) {
1
1613
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 mail page and customer can get the radio button value Please help me Thanks
0
8380
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8598
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7310
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.