Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Types of buttons 1

Status
Not open for further replies.

cedivad

Vendor
Jul 23, 2002
14
GB
Hi, can I set the type of a button to the reset type and viceversa?

I need to reset to blank a text field value, since the default value is not blank.

function clearDefaultValues(){
document.forms[0]['Clear '].type="button";
var field = document.getElementById('confirmPassword');
field.value = "";
}
This function is good for Mozilla, but in IE I've a jsError { Could not get the type property. This command is not supported.}
 

Seems to be treated as read-only.

You'll need to replace it. Have a look at this for an idea of what to do:
Code:
function clearDefaultValues() {

	var el = document.forms[ 0 ].elements( "clear" );

	var replacement = document.createElement( "INPUT" );
	replacement.setAttribute( "type", "reset" );
	replacement.setAttribute("name", "clear" );

	el.parentNode.replaceChild( replacement, el );
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top