March 4, 2012

Set value of hidden html label in php

Question by user1247412

I wish to change the value of html hidden label to a value of php variable. . And set its visibility to true. Can anyone tell me how to do this?

Answer by Jordan

<?php

    $errorMessage = "Yes, there was an error";

?>

...

<?php
    if ($errorMessage) {
        print("<p>$errorMessage</p>");
    }
?>

I hate PHP so much.

Answer by Starx

Labels cannot be hidden, unless CSS is used.

To hide an element by default, use hidden element as

<input type="hidden" />

In case of using CSS is acceptable

CSS

.hidden { visibility: hidden; }

PHP

<?php $labelvalue = "somevalue"; ?>
<label for="someinput" name="somename" class="hidden"><?php echo $labelvalue; ?></label>

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!