NYCPHP Meetup

NYPHP.org

[nycphp-talk] Removing Text from an Input Box

Andy Dirnberger dirn at dirnonline.com
Wed Jun 6 21:08:21 EDT 2007


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





More information about the talk mailing list