SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: passing function parmeter
-
Jan 8, 2008, 03:54 #1
- Join Date
- Mar 2005
- Posts
- 276
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
passing function parmeter
Hi,
I have this really simple function and for the life of me i cant remember how to pass the fieldname which is passed in the function.
Code JavaScript:function Change(fieldName) { if(document.mainDetails.enable.checked == true) { document.mainDetails.fieldName.disabled = false; } else { document.mainDetails.fieldName.disabled = true; } }
put me out of my misery please.
Thanks
CHris
-
Jan 8, 2008, 04:13 #2
- Join Date
- Jan 2005
- Location
- Too far up north
- Posts
- 1,566
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:Change("my_field_name");
-
Jan 8, 2008, 04:43 #3
- Join Date
- Mar 2005
- Posts
- 276
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks for replying.
i am already passing the field name ok as if I do
alert(fieldName); I can see it. but how do I pass that to the
document.mainDetails.fieldName.disabled = false; line as that brings an error saying it cant find an element called fieldName
Thanks
CHris
-
Jan 8, 2008, 04:48 #4
- Join Date
- Jan 2007
- Location
- Christchurch, New Zealand
- Posts
- 14,729
- Mentioned
- 104 Post(s)
- Tagged
- 4 Thread(s)
Code Javascript:document.mainDetails[fieldName].disabled = false;
-
Jan 8, 2008, 04:59 #5
- Join Date
- Mar 2005
- Posts
- 276
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks, I was using curly brackets instead of square brackets
Bookmarks