NYCPHP Meetup

NYPHP.org

[nycphp-talk] Removing Text from an Input Box

CED Consult at CovenantEDesign.com
Wed Jun 6 21:20:15 EDT 2007


or...

<script>
function clearField(id, value) {
   if (id.value == value) {
     id.value = "";
   }
}
function restoreField(id, value) {
   if (id.value == "") {
     id.value = value;
   }
   if (id.type == "text" && id.id == "pwrd" && id.value != "Password"){
     id.type = "password";
  } else {
  id.type = "text";
  }
}
</script>

----- Original Message ----- 
From: "Andy Dirnberger" <dirn at dirnonline.com>
To: "'NYPHP Talk'" <talk at lists.nyphp.org>
Sent: Wednesday, June 06, 2007 9:08 PM
Subject: RE: [nycphp-talk] Removing Text from an Input Box


> Something along these lines should work.
>
> <div id="passwordcontainer">
>   <input type="text" value="Password" onfocus="swapOut
('passwordcontainer',
> 'password');" />
> </div>
>
> function swapOut (container_id, field_name) {
>   var el = document.getElementById (container_id);
>   el.innerHTML = "<input type='password' name='" + field_name + "' />";
> }
>
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On
> Behalf Of Mark Armendariz
> Sent: Wednesday, June 06, 2007 9:02 PM
> To: 'NYPHP Talk'
> Subject: RE: [nycphp-talk] Removing Text from an Input Box
>
> >> From: talk-bounces at lists.nyphp.org
> [mailto:talk-bounces at lists.nyphp.org] On Behalf Of Ben Sgro
(ProjectSkyline)
>
> What im trying to do is turn that type to a password..so I can see
> the text...is that possible.
>
>
>
> Yes it is possible to change a field type to text and then back to
password
> in Firefox, but you'll get errors from IE and opera.  They don't like the
> idea of changing form field types.
>
> The way I've gotten around this is by creating an new field (innerHtml),
> using the old field's values, and then replacing the old field.  It's a
lot
> easier than it sounds using a framwork's insertion methods
> (prototype::Insertion.Before), though shouldn't terribly difficult using
> straight javascript.
>
> Mark
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>





More information about the talk mailing list