PDA

View Full Version : Input button to text link



mtdon1
Nov 22nd, 2010, 05:14 AM
Hi all,

I am working with a php code that I am trying to edit a bit. The last part I am trying to change I cannot figure out.

Essentially I want to change the "Login" submit button to just a text link that says "Login" instead.


<form action="<?php echo JRoute::_( 'index.php', true, $params->get('usesecure')); ?>" method="post" name="login" id="form-login" >
<?php echo $params->get('pretext'); ?>

<input id="modlgn_username" type="text" name="username" class="inputbox" alt="username" size="15" value="<?php echo JText::_('Username') ?>" onclick="login.username.value='';" />&nbsp;
<input id="modlgn_passwd" type="password" name="passwd" class="inputbox" size="15" alt="password" value="<?php echo JText::_('Password') ?>" onclick="login.passwd.value='';" />&nbsp;



<?php if(JPluginHelper::isEnabled('system', 'remember')) : ?>

<label for="modlgn_remember"><?php echo JText::_('Remember me') ?></label>
<input id="modlgn_remember" type="checkbox" name="remember" class="inputbox" value="yes" alt="Remember Me" />&nbsp;

<?php endif; ?>
<input type="submit" name="Submit" class="button" value="<?php echo JText::_('LOGIN') ?>" />&nbsp;



<?php

I am hoping this is just a minor change. Would someone mind showing me what I have to do?

Thanks very much.

poyzn
Nov 22nd, 2010, 06:40 AM
<a href="#" onclick="this.form.submit();">Login</a>

durangod
Nov 22nd, 2010, 01:20 PM
only my preference i prefer to show a dead link on something like that..

<a href="javascript:void(0);" onclick="this.form.submit();">Login</a>

mtdon1
Nov 23rd, 2010, 02:55 AM
Thanks guys.

Do I just replace the entire line of code that I bolded with your code?

I tried doing that and it stopped working. Do I need to place your code somewhere inside the bolded code?

Thanks.

mtdon1
Nov 25th, 2010, 04:55 PM
Hey guys -

Any help here? Maybe I need to change the "this.form.submit" part of it?

Thanks.

poyzn
Nov 25th, 2010, 07:42 PM
just replace the bolded code with it. by the way where is the closing form tag?

mtdon1
Nov 26th, 2010, 07:47 PM
Something seems to be missing, because when I simply replace the bolded code above with one of the two suggestions, I cannot login anymore.

Here is the full code:

<form action="<?php echo JRoute::_( 'index.php', true, $params->get('usesecure')); ?>" method="post" name="login" id="form-login" >
<?php echo $params->get('pretext'); ?>

<input id="modlgn_username" type="text" name="username" class="inputbox" alt="username" size="15" value="<?php echo JText::_('Username') ?>" onclick="login.username.value='';" />&nbsp;
<input id="modlgn_passwd" type="password" name="passwd" class="inputbox" size="15" alt="password" value="<?php echo JText::_('Password') ?>" onclick="login.passwd.value='';" />&nbsp;



<?php if(JPluginHelper::isEnabled('system', 'remember')) : ?>

<label for="modlgn_remember"><?php echo JText::_('Remember me') ?></label>
<input id="modlgn_remember" type="checkbox" name="remember" class="inputbox" value="yes" alt="Remember Me" />&nbsp;

<?php endif; ?>
<a href="#" onclick="this.form.submit();">Login</a>&nbsp;



<?php
$usersConfig = &JComponentHelper::getParams( 'com_users' );
if ($usersConfig->get('allowUserRegistration')) : ?>

<a href="<?php echo JRoute::_( 'index.php?option=com_user&task=register' ); ?>">
Register</a>

<?php endif; ?>

&nbsp;<a href="www.google.com">Help</a>

<?php echo $params->get('posttext'); ?>

<input type="hidden" name="option" value="com_user" />
<input type="hidden" name="task" value="login" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>

Fou-Lu
Nov 26th, 2010, 07:57 PM
This doesn't have anything to do with php. Moving from PHP forum to Javascript forum.

mtdon1
Nov 27th, 2010, 02:42 AM
I apologize, I didn't realize. Thanks for moving.

Any help guys?

Thanks!

Logic Ali
Nov 27th, 2010, 03:48 AM
Something seems to be missing, because when I simply replace the bolded code above with one of the two suggestions, I cannot login anymore.

<a href="#" onclick="this.form.submit();">Login</a>
You should use the error console. A link is not a form element so this cannot be used to reference the form.


<a href="#" onclick="document.getElementById('form-login').submit();">Login</a>

Although you must realise that this is inoperable if JS is not available.

You could submit with an image-type element:

<input type='image' src='An_Image_That_Looks_Like_A_Link.gif'>

mtdon1
Nov 27th, 2010, 08:03 PM
Perfect. It works. I knew I must need to include the form ID somehow.

Thanks a bunch for your help!

mtdon1
Dec 5th, 2010, 01:54 AM
Hey guys -

I need a little more help with this one. I forgot about the "Logout" button too! It seems to be a bit different from the login section, that's why I am asking. Again, I would like this to be a text link, not a button.


<div id="jtphorzlogin">
<?php if($type == 'logout') : ?>
<form action="index.php" method="post" name="login" id="form-login">
<?php if ($params->get('greeting')) : ?>

<?php if ($params->get('name')) : {
echo JText::sprintf( 'HINAME', $user->get('name') );
} else : {
echo JText::sprintf( 'HINAME', $user->get('username') );
} endif; ?>

<?php endif; ?>

<input type="submit" name="Submit" class="button" value="<?php echo JText::_( 'BUTTON_LOGOUT'); ?>" />


<input type="hidden" name="option" value="com_user" />
<input type="hidden" name="task" value="logout" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
</form>


Thank you!

mtdon1
Dec 8th, 2010, 01:08 AM
Any ideas here?

Thanks!

Old Pedant
Dec 8th, 2010, 01:39 AM
??? How is this any different???



<a href="#" onclick="document.getElementById('form-logout').submit();">Logout</a>

Assuming you have <form id="form-logout"> of course.

mtdon1
Dec 8th, 2010, 04:21 AM
This doesn't seem to work. I also have lost the ability to just hit "Enter" and have the login submitted.

I have to actually click on the link.

mtdon1
Dec 10th, 2010, 04:48 AM
Hey guys -

I still need some help here. I have been playing around with it but I can't seem to find a "logout" form id, which is why I am lost and why I think this logout code will be a bit different from the login code.

Any ideas?

mtdon1
Dec 12th, 2010, 08:11 AM
Fixed the link.

Does anyone know how I can add a submit via the enter key with a text link like this?

Thanks.

DJCMBear
Dec 12th, 2010, 01:50 PM
Add the code in the link onclick to an onsubmit element on the form tag so like this.

onclick="this.form.submit();"

Add it to this

<form onsubmit="this.form.submit();">

mtdon1
Dec 13th, 2010, 03:01 AM
Thanks DJCM. Can you be a bit more specific though. Where am I adding which part of the code?

I thought I needed to use some variation of onkeypress?


Thanks!

DJCMBear
Dec 13th, 2010, 02:13 PM
Sorry I thought you may know what you are editing, basicly where ever you added your link to login which has the JavaScript code in the onclick you just need to add an on submit element to the login form tag like in my previous post.

The same goes for the logout, I would also suggest having noscript tags around a form submit button for users that don't have JavaScript turned on, not many people turn it off but it's better to be safe than sorry.