How can i disable and enable form using checkbox?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AmiraSan
Forum Newbie
Posts: 4
Joined: Fri Dec 23, 2011 7:49 pm

How can i disable and enable form using checkbox?

Post 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 ?? :(
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post by Christopher »

You need to use Javascript to catch the onSubmit event. You can also disable the buttons and fields with Javascript too.
(#10850)
Gopesh
Forum Contributor
Posts: 143
Joined: Fri Dec 24, 2010 12:48 am
Location: India

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

Post 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...
AmiraSan
Forum Newbie
Posts: 4
Joined: Fri Dec 23, 2011 7:49 pm

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

Post by AmiraSan »

Thank you very much !
Post Reply