#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Make radio button invisible using php?


    Hi all,

    This is my first post ever, so please be gentle...

    I've been struggeling with the following problem. I have a form that contains a number of radio buttons. In some cases (depending on data in my sql database) I want some of the radio buttons to appear invisible (for a more user friendly form). Somehow I can't get it to work.

    Below a (simplified) version of the code I am using so far:

    Code:
    <?php $visible="display:none;";?>
    
    //Then for the radio buttons I am using this line of code to get the style tag to match $visible (in this case "display:none;). 
    
    <input name="question1" value="1" style="<?php echo($visible); ?>" type="radio">
    Could you please help out a struggeling beginner?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    the Netherlands
    Posts
    2
    Rep Power
    0
    It's much easier to put your input-tag in an if-statement
    PHP Code:
    if($visible){
    echo 
    "<input .... />"

    EDIT: The variable $visible is a boolean with the result of your visible-conditions
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by SimonBlok
    It's much easier to put your input-tag in an if-statement
    PHP Code:
    if($visible){
    echo 
    "<input .... />"

    EDIT: The variable $visible is a boolean with the result of your visible-conditions
    It worked like a charm! You've made my day, thanks a bunch!

IMN logo majestic logo threadwatch logo seochat tools logo