Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Radio Button Issues

 
Brad Jackson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21136
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 297
5
Android Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic