Jump to content

Javascript Display issue


billy_111

Recommended Posts

Hey,

 

Take a look at this page:

 

http://www.freemanholland.com/babies/

 

I have 2 Divs 'sign-up' and 'sign-up-two' and i use Javascript to display each one depending on the clicking of a link.

 

Now When you click on "Already a member? Click here to login", You will see a login box. When you submit the form the page reloads. I want the box to remain showing the login form..

 

I tried doing this:

 


<?

    if(isset($_POST['register'])){ ?>

        <script type="text/javascript" language="javascript">

        document.getElementById('sign-up').style.display='none';

        document.getElementById('sign-up-two').style.display='block';

        </script>

    <?

        if(isset($_POST['email']) && $_POST['email'] != '' && isset($_POST['password']) && $_POST['password'] != '')

        {

            if(User::AuthenticateSiteUser()){

            }else{

                $error = "<div class=\"error\">Email or Password incorrect.</div>";

            }

        }

    }

    ?>

 

But it didn't work..

 

Any ideas how i can do this??

 

Thanks again

Billy

Link to comment
https://forums.phpfreaks.com/topic/204388-javascript-display-issue/
Share on other sites

Another way you can do it is this.

 

Instead of specifying in the CSS file whether it is hidden or a block level element, do it in the style attribute.

 

For example.

 

if(isset($_POST['formData'])){
$signUpOneStyle = "none";
$signUpTwoStyle = "block";
}else{
$signUpOneStyle = "block";
$signUpTwoStyle = "none";
}

 

Then, in your <div> tag, set the style attribute like so:

 

<div style="display: <?php echo $signUpOneStyle; ?>" id="sign-up"></div>

 

Hopefully that makes sense.

 

Best of luck.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.