Page 1 of 1

How can i disable and enable form using checkbox?

Posted: Fri Dec 23, 2011 8:06 pm
by AmiraSan
Hello ,

I'm facing a problem disabling and enabling form using checkbox?

here's my code "i'm using php" :

<input type="checkbox" name="Participation" value="Paper"/>Paper</br>

<form action="./upload.php" method="post" enctype="multipart/form-data" >
<label for="file">Select a file:</label> <input type="file" name="userfile" id="file">

<input type="Submit" value="Upload">
</form>

I've used lots of methods including javascript !
but no use :(

i want to enable the form when i check the box and disable it when i remove the check .
the default status of the form is "disabled"

any ideas ?? :(

Re: How can i disable and enable form using checkbox?

Posted: Fri Dec 23, 2011 8:14 pm
by Christopher
You need to use Javascript to catch the onSubmit event. You can also disable the buttons and fields with Javascript too.

Re: How can i disable and enable form using checkbox?

Posted: Fri Dec 23, 2011 11:30 pm
by Gopesh
Hi,As Christopher said it can be done by using javascript or jquery.
Check this Fiddle http://jsfiddle.net/5pWHb/1/.
Here i used jquery for enabling and disabling form elements. U need to add the jquery core library file in the head section as

Code: Select all

<script type="text/javascript" src="jquery-1.6.4.js"></script>

Hope it helps u...

Re: How can i disable and enable form using checkbox?

Posted: Sat Dec 24, 2011 5:32 am
by AmiraSan
Thank you very much !