Jump to content

show/hide login form issue


deepson2

Recommended Posts

Hello,

 

I am working on hide/show login panel. it seems got stucked with my JS function. using this function showall/hideall function is necessary. besides that i want to show my user name and passwords textboxes at time not sea pertly.

 

can anyone please guide me. how can i achieve this?

here is my js code.

 function elemOn(elem_id){
    	if(document.getElementById(elem_id))
   document.getElementById(elem_id).style.display = "block";
    }

    function elemOff(elem_id){
if(document.getElementById(elem_id))
	document.getElementById(elem_id).style.display = "none";
    }
    function hideAll(){
for( var i = 1; i <= 4; i++ )
	elemOff( 'div'+i );
    }

    function showAll(){
for( var i = 1; i <= 4; i++ )
	elemOn( 'div'+i );
    }

    function showOne(elem_id){
hideAll( );
elemOn( elem_id );
    }

 

and here is my php code

<fieldset>
<a href="javascript:showOne('div1');">Login</a>
<div class="row">
<label for="username">Username</label><input type="text" name="username" id="username" value="<?=$username;?>" title="Enter your username" size="9" class="textboxfield" />

<label for="passwd">Password</label>
<input type="password" name="passwd" id="passwd" title="Enter your Password" value="<?=$passwd;?>" size="9" class="textboxfield" onkeypress="javascript: return specChar(event); maxlength=15" />
</div>
</fieldset>

 

when i keep both the text boxes then this function is not working. while if i keep only one texbox its working.

 

any help will be appreciated

thanks in advance.

 

Link to comment
Share on other sites

Showing or hiding a login form is not really something you dynamically do using javascript in the browser because the browser and javascript don't directly know if the visitor is logged in or not.

 

You do this using server side script by only outputting the log in form if the visitor is not logged in.

Link to comment
Share on other sites

Thanks for your reply PFMaBiSmAd,

 

I just don't want user to go to login.php page. if he/she wants to log in on index page just clicking on login link they can see this two text boxes and over there only they can do their log in.

 

just like digg.com earlier had. i dont know the other sites.

 

I think, this can be done using java script only. kinda of new to JS/AJAX.

 

please help me.

Link to comment
Share on other sites

Login links, login forms, logout links, Welcome: username messages and any other content on a page that changes depending on if a visitor is logged in or not, is not done using javascript. It is done using server side script to control what is output depending on if the visitor is logged in or not.

 

If you have a separate login page (I don't know why people do that instead of including a login/logout content "box" on any page that needs it), the log in page would test if the current visitor is logged in or not and only display the login form if he is not.

Link to comment
Share on other sites

Login links, login forms, logout links, Welcome: username messages and any other content on a page that changes depending on if a visitor is logged in or not, is not done using javascript.

 

you are right but using JS/ajax we don't need to go to different page(login.php)

we can do the login on that page(index page) itself. (besides its look good also... that what they said  :))

 

I have done this using thick boxes. but i don't want that. i want to do this using hide/show method.

 

something like this.

http://web-kreation.com/demos/login_form_mootools_1.2/

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.