473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

disable all elements from all forms except <textarea>'s

Hello,

I have a dynamic page of which I don't know how many forms will be on
it, neither which and how many elements will be in each form.

I use the following java script to disable all elements from all
forms:

var numberForms = document.forms.length;
var formIndex;
for (formIndex=0; formIndex<numberForms; formIndex++)
{
for(x=0;x<document.forms[formIndex].length;x++)
{ document.forms[formIndex].elements[x].disabled=true }
}

Now I want this to stay the same, except when an element is a
<textarea>. So basically: script must have the same functionallity
(disable all form elements), but not if the element is a textarea
(then it would remain enabled).

Is there a way to read out this <textarea> value in script ?

Thanks,
Bart
Jul 23 '05 #1
3 7144
Bart Van der Donck wrote:
Now I want this to stay the same, except when an element is a
<textarea>.


var aForms = document.forms,
nForms = aForms.length,
i;
for (i=0; i<nForms; i++) {
var aElems = aForms[i].elements,
nElems = aElems.length,
j;
for (j=0; j<nElems; j++) {
if (aElems[j].type != "textarea") {
aElems[j].disabled = true;
}
}
}

ciao, dhgm
Jul 23 '05 #2
Bart Van der Donck wrote:
Hello,

I have a dynamic page of which I don't know how many forms will be on
it, neither which and how many elements will be in each form.

I use the following java script to disable all elements from all
forms:

var numberForms = document.forms.length;
var formIndex;
for (formIndex=0; formIndex<numberForms; formIndex++)
{
for(x=0;x<document.forms[formIndex].length;x++)
{ document.forms[formIndex].elements[x].disabled=true }
}

Now I want this to stay the same, except when an element is a
<textarea>. So basically: script must have the same functionallity
(disable all form elements), but not if the element is a textarea
(then it would remain enabled).

Is there a way to read out this <textarea> value in script ?

Thanks,
Bart


var frm,
nForms = document.forms.length,
i = 0,
el,
els,
j,
nEls;
for (; i < nForms; ++i)
{
els = document.forms[i].elements;
for (j = 0, nEls = els.length; j < nEls; ++j)
{
el = els[j];
if ('undefined' != typeof el.disabled)
el.disabled = (el.type != 'textarea');
}
}

Jul 23 '05 #3
Bart Van der Donck <ba**@nijlen.com> wrote in message
news:b5**************************@posting.google.c om...
Hello,

I have a dynamic page of which I don't know how many forms will be on
it, neither which and how many elements will be in each form.

I use the following java script to disable all elements from all
forms:

var numberForms = document.forms.length;
var formIndex;
for (formIndex=0; formIndex<numberForms; formIndex++)
{
for(x=0;x<document.forms[formIndex].length;x++)
{ document.forms[formIndex].elements[x].disabled=true }
}

Now I want this to stay the same, except when an element is a
<textarea>. So basically: script must have the same functionallity
(disable all form elements), but not if the element is a textarea
(then it would remain enabled).

Is there a way to read out this <textarea> value in script ?

Thanks,
Bart


Just add 1 line to test the 'type' property:

var numberForms = document.forms.length;
var formIndex;

for (formIndex=0; formIndex<numberForms; formIndex++)
for(x=0;x<document.forms[formIndex].length;x++)
if(document.forms[formIndex].elements[x].type!='textarea')
document.forms[formIndex].elements[x].disabled=true;
--
S.C. http://makeashorterlink.com/?H3E82245A

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matt | last post by:
Simple vbscript,html page loading into access. Input pg posting to Confirm pg, then sending to access. when using; <textarea name="name" tabindex="15"> </textarea> as an input renders tab...
1
by: Augustus | last post by:
Hiya, I have a form with a <textarea></textarea> to receive user input. This input is then stored in a database and sent by fax... I need to be able to remove the carriage returns (enter...
2
by: Jonathan Taub | last post by:
This may seem a stupid question. I've got a <textarea> element: .... <td> List of items: <textarea> 1. Apple 2. Orange 3. Box
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
3
by: Jarek Mielcarek | last post by:
hi all, in xml file I have some fields which are source for <textarea> element. I'd like to transform this file using xslt and set the rows property of <textarea> depend of lines in some source...
8
by: ASP Yaboh | last post by:
I have an ArrayList of data gathered from a database. I want to create a web page from this data by creating a <table>, each cell in each row displays the appropriate data. One of those cells in...
10
by: Wayne Wengert | last post by:
Is there a way for ASP.NET/VB codebehind to get the contents of a plain old <textarea> element? I added an id='myname' to the <textarea> tag but VSNET complains that it is undefined? Wayne
3
by: FunkHouse9 | last post by:
I'm working on a form to collect data in a textarea which and am trying to keep returns and spaces. I have a couple of functions that I Frankensteined together to replace returns with <br> and to...
7
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
I need to emulate the missing "maxlegth" attribute in "textarea" fields but all my Google searches either lead to obsolete scripts that overwrite the "value" property (thus losing caret position)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.