Submitting the unsubmittable

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
User avatar
harrison
Forum Commoner
Posts: 30
Joined: Thu Jun 09, 2005 12:23 am

Submitting the unsubmittable

Post by harrison »

Hi,
I made a form with a DISABLED CHECKED checkbox, because I detected that the user is not allowed to disagree with that option.
But whenever this form is submitted, it never submit the checkbox. What is this happenning?
If you want me to show the code, I will but I think it is that simple.
Please help me with this.
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

why dont you just make it so that if they dont check it then when they press the submit button it goes to a page that says "you must agree with ..." or somthin like that?
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Submitting the unsubmittable

Post by Roja »

harrison wrote:Hi,
But whenever this form is submitted, it never submit the checkbox. What is this happenning?
Disabled elements are not submitted. Read-only are.
asmie
Forum Newbie
Posts: 11
Joined: Mon Jun 20, 2005 8:45 am

Post by asmie »

Hie,

You will have to apply javascript validation.
The form should be submitted only if the user agrees else the form should not get submitted.
You can try this :

Code: Select all

<script>
function validate(obj)
{
   if(obj.value == &quote;agree&quote;)
	{
		document.form1.btnSubmit.disabled = false;
    }
	else
	{
		document.form1.btnSubmit.disabled = true;
	}
}
</script>

<form action=&quote;&quote; method=&quote;post&quote;  name=&quote;form1&quote;>
<p>
    <input type=&quote;radio&quote; name=&quote;myradio&quote; value=&quote;agree&quote; onClick=&quote;validate(this)&quote;>
  Agree
  <input type=&quote;radio&quote; name=&quote;myradio&quote; value=&quote;disagree&quote; onClick=&quote;validate(this)&quote;>
  Disagree
</p>
<p>
  <input type=&quote;submit&quote; name=&quote;btnSubmit&quote; value=&quote;Submit&quote; disabled>
</p>
</form>

Asmie
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

If he isn't allowed to do it... he shouldn't rely on it, as he would eitherway have to check that value to make sure the user didn't "change the matrix" ;).

So, disabled checkboxes not being sent is more of a feature if you ask me, as if it is disabled, YOU should know the answer to it, and he should not by any means be able to specify something else.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

if you really want it then you could store the value in a hidden field with the name of the check box and change the name of the disable checkbox.

Wouldn't neccessarly stop someone from changing it but at least you would have the value.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Re: Submitting the unsubmittable

Post by patrikG »

Roja wrote:Disabled elements are not submitted. Read-only are.
is the solution.

Code: Select all

<input name=&quote;putmein&quote; type=&quote;text&quote; size=&quote;8&quote; value=&quote;&euro; 699.-&quote; readonly=&quote;readonly&quote;>
Post Reply