Cheers for the info barry. What i was after was x amount of form fields to
be passed to the function, so after a little head scratching i wrote this
and it works!

<SCRIPT Language="JavaScript">

//ENABLE FORM ELEMENTS
function turnmeon() {
    // ARRAY OF ARGUMENT VALUES
    var argv = turnmeon.arguments;
    // THE NUMBER OF ARGUMENTS PASSED TO THIS FUNCTION
    var argc = argv.length;
    // LOOP THROUGH THE ARGUMENTS (0 THROUGH N-1)
    for (var i = 0; i < argc; i++) {
        // WRITE OUT THE ARGUMENT VALUES
        document.getElementById(argv[i]).disabled = false;
    }
}
//DISABLE FORM ELEMENTS
function turnmeoff() {
    // ARRAY OF ARGUMENT VALUES
    var argv = turnmeoff.arguments;
    // THE NUMBER OF ARGUMENTS PASSED TO THIS FUNCTION
    var argc = argv.length;
    // LOOP THROUGH THE ARGUMENTS (0 THROUGH N-1)
    for (var i = 0; i < argc; i++) {
        // WRITE OUT THE ARGUMENT VALUES
        document.getElementById(argv[i]).disabled = true;
    }
}

</SCRIPT>

You can pass the form elements id's to it and it will enable/disable them

jamo

> Jamie:
> 
> have it disabled as it renders (ie: pre-set in the code) and use an =
> onClick (onSelected for list boxes, etc) to enable it.
> 
> example: clicking in the textbox will enable the button
> <form name=3D"theForm" action=3D"" method=3D"get"><input =
> name=3D"theText" type=3D"text" value=3D"theValue" =
> onClick=3D"turnMeOn(theForm.theButton)">
> <input name=3D"theButton" type=3D"button" disabled=3D"true" =
> value=3D"theValue" >
> </form
> 
> using simple JS like this does all the hard work
> <script language=3D"JavaScript">
> function turnMeOn(element){
>       element.disabled =3D false
> }
> </script>
> 
> cheers
> Barry Beattie
> CF Web Developer
> Alpha Business Systems
> [EMAIL PROTECTED]
> =A0
> Ph: +61 07 3216 0999
> =A0
> Unit 1, 31 Thompson Street
> Bowen Hills QLD 4006
> www.alphabus.com.au
> =A0
> Virus Disclaimer: blah...
> Confidentiality: blah...
> 
> 
> 
> -----Original Message-----
> From: Jamie Lawrence Jenner [mailto:[EMAIL PROTECTED]
> Sent: Friday, 11 June 2004 3:54 AM
> To: CFAussie Mailing List
> Subject: [cfaussie] disable form elements
> 
> hi,
> 
> I know its not cf but i really need help
> 
> I have a form which has three questions
> 
> 1 MOT =3D checkbox =3D yes, checkbox =3D no
> 
> motday - motmonth - motyear
> 
> 2 Tax =3D checkbox =3D yes, checkbox =3D no
> 
> taxday - taxmonth - taxyear
> 
> 3 Warranty =3D checkbox =3D yes, checkbox =3D no
> 
> Warday - Warmonth - Waryear
> 
> 
> basically waht i need is for the date selectores to all be set to =
> disabled
> when the form loads. Then if a user clicks on the yes checkbox, the =
> dates
> for that qustion enable.
> 
> i have found many scripts to do this with single elements, but not to
> unlock three form elements.
> 
> Ideally what i need is a function whcih can be passed x amounts of for
> elements, then loop through it and dsable, enable the form elements =
> passed
> 
> I have spent ages trying to do it myself but i have only used js a =
> couple
> of times!
> 
> cheers in advance
> 
> jamo
> 
> 
> 
> 
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to =
> [EMAIL PROTECTED]
> Aussie Macromedia Developers: http://lists.daemon.com.au/

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to