Jump to content

[SOLVED] Help in button disable


mmarif4u

Recommended Posts

<?php 
$con = mysql_connect("localhost","root","adil"); 
if (!$con) 
  { 
  die('Could not connect: ' . mysql_error()); 
  } 
mysql_select_db("db", $con); 
$query = "SELECT * FROM accdtl where icnumber='123456-00-0012'"; 
$result = mysql_query($query) or die(mysql_error()); 
$ic=$row->icnumber; 
if ($ic == '123456-00-0012') { 
     $disabled = "disabled"; 
     } 
else{ 
    $disabled = ""; 
   } 
echo "<table class='text' align=Center CELLSPACING='0'BORDERCOLOR='#007FFF' BGCOLOR='cornsilk' border='1'> 
<tr><th colspan=12><Font face='Verdana'size='3'>Official Receipt</th></Font> 
<tr> 
<th><Font size='1'>Customer IC</th></Font> 
<th><Font size='1'>Acc Code</th></Font> 
<th><Font size='1'>Active</th></Font> 
<th><Font size='1'>Date</th></Font> 
</tr></tr>";while($row = mysql_fetch_array($result)) 
  { 
  echo "<tr>"; 
  echo"<td>" . $row['icnumber'] . "</td></font>"; 
  echo "<td>" . $row['acccode'] . "</td></font>"; 
  echo "<td>" . $row['active'] . "</td></font>"; 
  echo "<td>". $row['date'] . "</td></font>";      
  echo "</tr>"; 
  } 
echo "</table>";mysql_close($con); 
echo ' 
<form> 
<input type="button"  onClick="window.print()" value="Selection by Set"  '.$disabled.' > 
</form> 
'; 
?>

This is the page where i want to disable the button but if the condotion is true.

I try the php but not working, i am not good in javascript.

How to use java for this to work.

Any help will be appreciated.

Thanks.

Link to comment
Share on other sites

I am not too sure on tis myself but here is what I think

change the following

if ($ic == '123456-00-0012') { 
     $disabled = "disabled"; 
     } 
else{ 
    $disabled = ""; 
   } 

 

to say

 

if ($ic == '123456-00-0012') { 
     $disabled = "True"; 
     } 
else{ 
    $disabled = "False"; 
   } 

 

and change this line to read

echo ' 
<form> 
<input type="button"  onClick="window.print()" value="Selection by Set"  disabled="'.$disabled.'" > 
</form> 
'; 

 

Link to comment
Share on other sites

I try this changes its ok working, but the problem is now that the

button is always disabled even i change the icnumber then also,

 

this simple coding driving me crazy.

I dont know where to correct it.

Any suggestions.

Thanks for reply.

Link to comment
Share on other sites

try it this way then

<?php
if ($ic == '123456-00-0012') { 
     $disabled = "disabled='true'"; 
     } 
else{ 
    $disabled = ""; 
   } 

echo ' 
<form> 
<input type="button"  onClick="window.print()" value="Selection by Set"  $disabled > 
</form> 
'; 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.