How can i disable an HTML button in a PHP Code?

How can i disable an HTML button in a PHP Code?

=== Start of my code

some code...
some other code...

      $GLOBALS['error']             = 1;
                              $GLOBALS['error_type']       = "error"; //ok,warn,error,info
                              $GLOBALS['error_msg']       = $PPT->_e(array('add','50'));

' HERE i need to insert a rule which will disable the button "submitMe" ... How can i do it? The button is already displayed on the page ....

Thank you!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
If the button is already displayed on the page, it's too late. PHP runs on the server, where it creates the HTML document containing the HTML markup, CSS and JavaScript.  By the time the client sees the web page, the server has disconnected and gone to sleep.  This explains the client/server protocol.

In the PHP action script you can simply ignore the button.  In the PHP script that creates the form you can omit the button.  If there is a specific client action like a checkbox or mouseclick that you want to follow, you can use JavaScript to enable or disable input controls like buttons, or to hide them completely.  The most popular JavaScript library is jQuery.
helenb1Author Commented:
Can you please go in this page?

Click on Select Plan.

On the next page go at the footer and click 'I Agree to ...' and you will see that the button will be activated, and if you un-check 'I agree' it will be disabled.

Any thoughts on this one?
Ray PaseurCommented:
Yes, this is jQuery.  This is from the "view source" at line 362

        <h4><span>5</span>Terms and Conditions</h4>
        <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#submitMe').attr('disabled', true);  }); 
        function UnDMe(){
			if ( jQuery('#submitMe').is(':disabled') === false) { 
				jQuery('#submitMe').attr('disabled', true);  jQuery('#submitMe').removeClass('green'); jQuery('#submitMe').addClass('gray');
			} else {
				jQuery('#submitMe').attr('disabled', false); jQuery('#submitMe').addClass('green');
        <!-- START TERMS BOX -->     
        <div class="green_box"><div class="green_box_content">         
            <input type="checkbox" id="agreeTC" name="interests" class="radio" tabindex="8" onclick="javascript:UnDMe();">
            <a href="" style="color:blue; text-decoration:underline;" target="_blank">I agree to the Terms and Conditions</a>
        <!-- END TERMS BOX -->    
	</fieldset> <!-- end fieldset form-->

	</div><!-- end inner itembox -->
	<!-- start buttons -->
    <div class="enditembox inner">
    <input type="button" onclick="window.location=''"  class="button gray right" tabindex="15" value="Cancel" />
    <input type="submit" name="submit" id="submitMe" class="button gray left" tabindex="15" value="Continue"/>
    </div><!-- end buttons -->

Open in new window

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

helenb1Author Commented:
ok .. thank you for the correction.

it is possible to do what i want? How can i disable the button in the php code?
Ray PaseurCommented:
It doesn't work that way.  PHP is run and done before the client even sees the web page.  The PHP code is completed.

If you can show me examples of what you're trying to achieve, I can probably show you how to do it, but it doesn't sound like a PHP thing so far - it sounds like jQuery.
helenb1Author Commented:
I am trying to disable the button.

I need to insert the JQUERY function (to call it) from the same .php file that the button exists.

Do you understand?

With other words i need something like...

Ray PaseurCommented:
OK, I can show you how to disable the button, but it's not done in PHP.  PHP is on the server.  The button is on the client.  The only way PHP becomes involved in this process is by generating the HTML document that gets sent to the client. The HTML document contains the jQuery statements that disable the button.
helenb1Author Commented:
ok please tell me how we can disable it?
Ray PaseurCommented:
Please see:

<?php // RAY_temp_helenb1.php

$htm = <<<HTML5
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(document).ready(function() { $('#submitMe').attr('disabled', true);  });

function UnDMe(){
    if ($('#submitMe').is(':disabled') === false){
		$('#submitMe').attr('disabled', true);
		$('#submitMe').attr('disabled', false);

<style type="text/css">
.gray  { background-color:lightgray; }
.green { background-color:lawngreen; }

<title>Toggle Submit Button On or Off</title>

Click Me: <input type="checkbox" onclick="javascript:UnDMe();">
<input type="submit" id="submitMe" class="button gray" value="Continue" />


echo $htm;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.