|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bbshetan Smarty n00b
Joined: 14 Jun 2009 Posts: 3
|
Posted: Sun Jun 14, 2009 2:18 pm Post subject: javascript |
|
|
language French=>
Bonjour, j'ai un petit soucis avec un code javascript et smarty
le code sans smarty (en html ou php) fonctionne très bien mais avec smarty il est pas pris en compte je dois faire une erreur quelque part pouvez vous m'aider s'il vous plait.
Ce code javascript sert a transformé un input text en password.
Voici une partie du code dans fichier index.tplt
Code: | {literal}
<script type="text/javascript">
<!--
function vider() {
document.getElementById('pseudo').value='';
// pour Firefox
//document.getElementById('password').value='';
//document.getElementById('password').type='password';
// pour IE
document.getElementById('div1').innerHTML = '<input type="password" id="password" value="" />';
}
function reinitialiser()
{
if(document.getElementById('pseudo').value == '')
{
document.getElementById('pseudo').value='Pseudo';
//document.getElementById('password').type='text';
//document.getElementById('password').value='Mot de passe';
document.getElementById('div1').innerHTML = '<input type="text" id="password" value="Mot de passe" />';
}
}
-->
</script>
{/literal}
==========
<form action='login.php' method='post'>
<input style="vertical-align:middle;" type='checkbox' name='persistent' value='1' id='rememberme'> <label style="color:#98a9ca; margin-right:70px; vertical-align:middle; cursor:pointer;" for='rememberme'>remeberme.php</label> <a style="color:#98a9ca; margin-right:65px; " href="lostpass.php">{lang_print id=675}</a>
<br>
<input type='text' class='text_index' name='email' size='23' maxlength='100' value='username'onclick="vider()" onblur="reinitialiser()" />
<input type='text' class='text_index' name='password' size='23' maxlength='100'value="password">
<input type='submit' class='button_index' value='login'>
<NOSCRIPT><input type='hidden' name='javascript_disabled' value='1'></NOSCRIPT>
<input type='hidden' name='task' value='dologin'>
<input type='hidden' name='ip' value='{$ip}'>
</form> |
ce script passe nickel sous firefox et IE sans la template smarty et avec smarty il est pas pris en compte
Merci pour votre aide
language English=>
Sorry for my English
Hello, I have small a concern with a code Javascript and smarty
the code without smarty (in HTML or php) functions very well but with smarty it is not taken into account I must make an error some share can you help me please.
This code Javascript is useful transformed an input text into password.
Here part of the code in file index.tplt
Code: | {literal}
<script type="text/javascript">
<!--
function vider() {
document.getElementById('pseudo').value='';
// pour Firefox
//document.getElementById('password').value='';
//document.getElementById('password').type='password';
// pour IE
document.getElementById('div1').innerHTML = '<input type="password" id="password" value="" />';
}
function reinitialiser()
{
if(document.getElementById('pseudo').value == '')
{
document.getElementById('pseudo').value='Pseudo';
//document.getElementById('password').type='text';
//document.getElementById('password').value='Mot de passe';
document.getElementById('div1').innerHTML = '<input type="text" id="password" value="Mot de passe" />';
}
}
-->
</script>
{/literal}
==========
<form action='login.php' method='post'>
<input style="vertical-align:middle;" type='checkbox' name='persistent' value='1' id='rememberme'> <label style="color:#98a9ca; margin-right:70px; vertical-align:middle; cursor:pointer;" for='rememberme'>remeberme.php</label> <a style="color:#98a9ca; margin-right:65px; " href="lostpass.php">{lang_print id=675}</a>
<br>
<input type='text' class='text_index' name='email' size='23' maxlength='100' value='username'onclick="vider()" onblur="reinitialiser()" />
<input type='text' class='text_index' name='password' size='23' maxlength='100'value="password">
<input type='submit' class='button_index' value='login'>
<NOSCRIPT><input type='hidden' name='javascript_disabled' value='1'></NOSCRIPT>
<input type='hidden' name='task' value='dologin'>
<input type='hidden' name='ip' value='{$ip}'>
</form>
|
this script passes well under firefox and IE without the template smarty and with smarty it is not taken into account
Thank you for your assistance
Last edited by bbshetan on Mon Jun 15, 2009 8:25 am; edited 2 times in total |
|
Back to top |
|
jLix Smarty Regular
Joined: 01 Apr 2009 Posts: 59 Location: Lowlands, EU
|
Posted: Sun Jun 14, 2009 10:08 pm Post subject: |
|
|
Compare the source code that your browser recieves (view source) of both the Smarty and non-Smarty template. _________________ http://jlix.net/extensions/smarty |
|
Back to top |
|
jLix Smarty Regular
Joined: 01 Apr 2009 Posts: 59 Location: Lowlands, EU
|
Posted: Sun Jun 14, 2009 10:24 pm Post subject: |
|
|
Perhaps the following is what causes the problem: Code: | value='username'onclick="vider()" | Should be: Code: | value='username' onclick="vider()" |
<offtopic>
It's advised not to use <noscript> as you can't rely on it. Sometimes proxy servers are setup to rip out all JavaScript code. The browser that recieves this stripped code may very well be able to run JavaScript code (and so ignores the <noscript>), but there's just no JavaScript code to run anymore.
So better leave out the <noscript> tags and use let JavaScript remove the hidden field. That way you're sure that JavaScript was able to run when the field is missing.
</offtopic>
And please put your code in code blocks. Makes it much easier to read. _________________ http://jlix.net/extensions/smarty |
|
Back to top |
|
bbshetan Smarty n00b
Joined: 14 Jun 2009 Posts: 3
|
Posted: Mon Jun 15, 2009 8:30 am Post subject: I'm |
|
|
Sorry for code |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|