aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Radio Button Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Radio Button Issues" Watch "Radio Button Issues" New topic
Author

Radio Button Issues

Brad Jackson
Greenhorn

Joined: Nov 26, 2012
Posts: 3
Hello Everyone,

Thank you to everyone who is able to help me up front.....

I am building the front-end web interface for a warehouse inventory system for my company owner. I have a page with (2) Radio Buttons. The first radio button is set to make a single text field appear and the second radio button is set to make the first text field as well as (9) more text fields appear. This section is for adding MAC addresses into the inventory with the same shipping information for all the MAC addresses. I only need to know how to make the Text Fields go from "Visibility:Hidden" to "Visible" when either of the Radio Buttons are selected. I'm utilizing Div tags for just about everything to keep the page organized. Any help getting this Script to work is appreciated.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

Hi Brad, welcome to the Ranch!

Your question sounds like it's about Javascript. The forum you posted in is about JSP, the server-side technology. So let me just move it over to our Javascript (and HTML) forum.

And by the way it might be helpful if you could add some more detail about your question, like for example some of the HTML which you're asking about, and some of the Javascript you have which isn't working for you yet.
Brad Jackson
Greenhorn

Joined: Nov 26, 2012
Posts: 3
Paul Clapham wrote:Hi Brad, welcome to the Ranch!

Your question sounds like it's about Javascript. The forum you posted in is about JSP, the server-side technology. So let me just move it over to our Javascript (and HTML) forum.

And by the way it might be helpful if you could add some more detail about your question, like for example some of the HTML which you're asking about, and some of the Javascript you have which isn't working for you yet.


Thank You kindly for the clarification, I apologize for the confusion on my end. The HTML I can provide but the Scripting isn't any good......I've been scrapping what I could from the internet and nothing has been working. I think it would be quite confusing if I posted my code with my CSS but I will do so if it clarifies. I know that my Var settings aren't correct but I was trying everything before I posted on here.

Brad Jackson
Greenhorn

Joined: Nov 26, 2012
Posts: 3
Here is my newest code revision......It still does not make the text field visibility change......Any help would be appreciated......

Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 297
    
    5

There are a number of obvious problems, let's start with them.

First, you are at no point calling the function showTextField(). You need to bind the function to the click event on your radio buttons.

Second, mac1.style.display is referencing an undefined variable. Use getElementById() to get a reference to the element:
document.getElementById('mac1').style.display.

Third this code, assuming that it was corrected as above, is first showing the element, then hiding it:

Do you want to show the element at this point, or hide it? Pick which one.

Fourth, although you're trying to set visibility through the display CSS attribute, on your mac1 element you're setting the visibility attribute, so the element will be hidden irrespective of what you set display to. Decide whether you want to use visibility or display and use them consistently.

Fifth, none of these things are defined anywhere in your code, so it's not clear what you're expecting to happen when you use them for comparisons or to set properties:

  • node
  • inpTxtArea
  • inpTxtBox


  • Overall, your code seems like a confused mish-mash. If you're not really sure what you're doing with JavaScript it may be easier to start with jQuery which has shortcuts for click handling and hiding and showing elements.


    Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Radio Button Issues