Web Analytics Made Easy -
StatCounter Input type.. needs refreshing - CodingForum

Announcement

Collapse
No announcement yet.

Input type.. needs refreshing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Input type.. needs refreshing

    i was working on having a input field clear from saying Password, with a type of text, to changing to password in php

    does anyone think they know how to fix this?

    PHP Code:
    <input name="password" size="10" onblur="if(this.value=='') {this.value='Password'; <?php $input_type='text'?>}" onfocus="if(this.value=='Password') {this.value=''; <?php $input_type='password'?>}" value="Password" type="<?php echo $input_type?>">

  • #2
    Unfortunately this wont work, as all the PHP code is ran before the user sees the page, and it will not run again within javascript.

    I dont know much about javascript, but could you not use something like:

    this.type = 'password'

    ?
    PHP Weekly - A PHP Developers Resource
    PHP 5.1.4 and Ruby on Rails web hosting
    Moderator of PHP and Work offers and Requests
    Install Apache/PHP/MySQL
    (by marek_mar) | TinyPlugin Architecture

    Comment


    • #3
      php

      thx for your help,

      unfortunatly i don't know much about java too, however, i do know that this.type='' doesn't work because an input type is only read only.. so i couldn't assign a variable to it

      i was hoping this could work... but i've been beginning to draw the same conclusion

      Comment


      • #4
        You are probably best off having it set as password input type always, becauase when the user is typing in their password it will still be visible as normal text until they blur the form, meaning people watching could still read their password if they saw them typing it.
        PHP Weekly - A PHP Developers Resource
        PHP 5.1.4 and Ruby on Rails web hosting
        Moderator of PHP and Work offers and Requests
        Install Apache/PHP/MySQL
        (by marek_mar) | TinyPlugin Architecture

        Comment


        • #5
          back

          well i'm back with i guess... THIS, and i get one slight problem... when it's in my table

          PHP Code:
          <script>
          function 
          pass1(theField){
            
          theField.style.display='none';
            
          pwdField theField.form.password;
            
          pwdField.style.display='block';
            
          pwdField.focus();
          }
          function 
          pass2(theField){
            if(
          theField.value==""){
              
          theField.style.display='none';
              
          noteField theField.form.pass;
              
          noteField.style.display='';
            }
          }
          </
          script>


          <
          input type="text"name="username" size="10" onblur="if(this.value=='') {this.value='Username';}" onfocus="if(this.value=='Username'){this.value='';}" value="Username">
             <
          input type="text" name="pass" size="10" onFocus="pass1(this)" value="Password">
             <
          input type="password" name="password" size="10" onBlur="pass2(this)" style="display:none"
          the code works all perfect and all... but anyone have any idea why it skips down a line?

          Comment

          Working...
          X