SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help in button disable

    PHP Code:
    <?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.

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Set $disabled="" outside the while loop.

    Put this part INSIDE the loop:
    Code:
    $ic=$row->icnumber;
    if ($ic == '123456-00-0012') { 
         $disabled = "disabled"; 
         }

  3. #3
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I try this changes, the problem is same,
    button is enabled

    this simple coding driving me crazy.
    I dont know where to correct it.
    Any suggestions.
    Thanks for reply.

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to echo the value stored in the variabl $disabled whether this it stores something or not. If it is storing as it should, then try out echoing like this:
    PHP Code:
    echo "<form>
    <input type=\"button\"  onClick=\"window.print();\" value=\"Selection by Set\"  " 
    $disabled " />
    </form>"

    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks rajug for reply,
    See my post in php forum for details.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •