Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

javascript

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
bbshetan
Smarty n00b


Joined: 14 Jun 2009
Posts: 3

PostPosted: Sun Jun 14, 2009 2:18 pm    Post subject: javascript Reply with quote

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'>&nbsp;
        <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'>&nbsp;
        <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
View user's profile Send private message
jLix
Smarty Regular


Joined: 01 Apr 2009
Posts: 59
Location: Lowlands, EU

PostPosted: Sun Jun 14, 2009 10:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jLix
Smarty Regular


Joined: 01 Apr 2009
Posts: 59
Location: Lowlands, EU

PostPosted: Sun Jun 14, 2009 10:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
bbshetan
Smarty n00b


Joined: 14 Jun 2009
Posts: 3

PostPosted: Mon Jun 15, 2009 8:30 am    Post subject: I'm Reply with quote

Sorry for code
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP