Click to See Complete Forum and Search --> : Changing appearance of form elements


biz
01-09-2003, 09:51 AM
Hello!
I have a form on my page with several elements.
I want to disable/enable a text box and radio buttons
and clear the values in the text box/reset the radio buttons on the click a different radio button.

I thought it would be quicker to put the names of the form element in an array and loop through them.

The extract of my code below works for the text box but not the radio button.

Can anyone let me know where I'm going wrong please?:confused:


Code:

var aryGrpB = ["txtArchFolder","radCopy[1]","radCopy[2]"];

//for every value in Grp array enable element
for ( var i = 0 ; i < aryGrpB.length ; i++ ) {
document.frm1[aryGrpB[i]].disabled = true;}

//for every value in Grp array clear value
for ( var i = 0 ; i < aryGrpB.length ; i++ ) {
document.frm1[aryGrpB[i]].value = '';}

swon
01-09-2003, 11:09 AM
That should works:

var aryGrpB = ["txtArchFolder","radCopy[1]","radCopy[2]"];

//for every value in Grp array enable element
for ( var i = 0 ; i < aryGrpB.length ; i++ ) {
document.YourForm.aryGrpB[i].disabled = true;}

//for every value in Grp array clear value
for ( var i = 0 ; i < aryGrpB.length ; i++ ) {
document.YourForm.aryGrpB[i].value = '';}

biz
01-09-2003, 11:31 AM
Hi Swon,
I previously tried that and got the error
'document.frm1.aryGrpB'is null or not an object

any other suggestions greatly appreciated!

swon
01-09-2003, 12:33 PM
Oh, I didnt' saw that:

var aryGrpB = ["txtArchFolder","radCopy[1]","radCopy[2]"];

is not a correct array;do

var aryGrpB =new Array("txtArchFolder","radCopy[1]","radCopy[2]");

biz
01-10-2003, 04:28 AM
Tried that too and still the same error!

swon
01-10-2003, 12:42 PM
Could you post the form with the javascript code?