> Sorry for the off topic post, but I was wondering if anyone knew of a
> way to change the "type" of a form input on the fly, using JavaScript.
> For example; I know I can change the value of "value" thusly:
> onFocus="this.value='My New Value'". I was hoping I could change the
> input type from text to password, onFocus. Of course
> onFocus="this.type='password'" did not work for me and I am, in all
> probability, delusional. :-) Any help would be appreciated!
well... I know that if you use onfocus="alert(this.type);" you'll get the
current type of the input... I'm not sure if it's a read-only property --
you might want to check the dhtml section of msdn.microsoft.com/library for
the specs on the <input> html element. I've been able to do some other stuff
with JS that I previously wouldn't have expected to be able to do, like
hiding and showing stuff with style.display, adding and removing whole
sections of html with .innerHTML, which you could do here, by bounding the
input field in a div and using a functioin in the onfocus like so:
function makepassword() {
var temp = document.myform.mytextfield.value;
var pass = '<input type="password" name="mytextfield" value="' + temp +
'">';
document.getElementById("mydiv").innerHTML = pass;
}
Out of morbid curiousity, why is it that you want to do this? ...
Isaac Dealey
Certified Advanced ColdFusion Developer
www.turnkey.to
954-776-0046
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists