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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make all <input taqs readonly

Status
Not open for further replies.

blexman

Programmer
Jul 18, 2001
34
0
0
CA
How can I make all elements of a form readonly without having to do it on each input tag ?

thanks
hanton
 
not sure but readonly may be a attribute you can use via style sheet
suedocode
INPUT {
readonly
}

I'll check it out but you might want to give it atry.
A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Yes I think you can do that...but I would like to dot some think like this..

<form namd=form1 action=&quot;x.asp&quot; <%if confirmation then 'set all input tags to readonly'%> <%end if%>>
 
How about looping through all the input tags on the page in one easy function?

Code:
function disableAll(){
	for(var i = 0;i < document.getElementsByTagName(&quot;input&quot;).length;i++){ 
		document.getElementsByTagName(&quot;input&quot;)[i].disabled = true;
	}
}

Basically loop through the entire count of inputs, setting each one to disabled. Be aware this also will disable submit inputs and that disabled inputs do not get passed in the form collection.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
With enough resources, time, and coffee, anything is possible.
 
If you wanted to disable ALL form elements, you could place a div containing a transparent gif on top of all the elements.

<div style=&quot;width:100%;height:100%;z-index:9999;position:absolute;top:0px;left:0px;&quot;>
<img src=&quot;images/clear.gif&quot; height=&quot;100%&quot; width=&quot;100%&quot; />
</div>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top