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!
helenb1Asked:
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.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html

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.
0
helenb1Author Commented:
Can you please go in this page?

http://bit.ly/19Tsm2i

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?
0
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');
			
			}		
		
		}
        </script>
        <!-- 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="http://www.linkslive.info/submission-guidelines/" style="color:blue; text-decoration:underline;" target="_blank">I agree to the Terms and Conditions</a>
           
        </div>
        </div> 
        <!-- END TERMS BOX -->    
            
		 
            
           
    
           
        
    
	</fieldset> <!-- end fieldset form-->

	</div><!-- end inner itembox -->
    
	<!-- start buttons -->
    <div class="enditembox inner">
    <input type="button" onclick="window.location='http://www.linkslive.info/submit/'"  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

0
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?
0
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.
0
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...

echo 'JQUERY DISABLE BUTTON_NAME';
0
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.
0
helenb1Author Commented:
ok please tell me how we can disable it?
0
Ray PaseurCommented:
Please see: http://www.laprbass.com/RAY_temp_helenb1.php

<?php // RAY_temp_helenb1.php
error_reporting(E_ALL);

// CREATE OUR WEB PAGE IN HTML5 FORMAT
$htm = <<<HTML5
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(document).ready(function() { $('#submitMe').attr('disabled', true);  });

function UnDMe(){
    if ($('#submitMe').is(':disabled') === false){
		$('#submitMe').attr('disabled', true);
		$('#submitMe').removeClass('green');
		$('#submitMe').addClass('gray');
	}else{
		$('#submitMe').attr('disabled', false);
		$('#submitMe').addClass('green');
	}
}
</script>

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

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

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

</body>
</html>
HTML5;

// RENDER THE WEB PAGE
echo $htm;

Open in new window

0

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
JavaScript

From novice to tech pro — start learning today.