Please login or register.

Login with username, password and session length
Advanced search  

News:

We are constantly trying to improve phpfreaks and these forums, so feel free to go to the PHPFreaks Comments/Suggestions board and point out anything you'd like to see different!

Maintenance Notice

PHPFreaks has successfully moved to a new Dedicated Server, hosted by Server Powered. Please help support future upgrades by Donating.

Author Topic: [SOLVED] Button Control  (Read 481 times)

0 Members and 1 Guest are viewing this topic.

OldManRiver

  • Member
  • Offline Offline
  • Posts: 56
    • View Profile
[SOLVED] Button Control
« on: January 03, 2008, 08:54:42 PM »
All,

Have a file posted at:

http://pastebin.ca/840828

with 5 buttons.  Problem is I'm having trouble getting the buttons to differentiate themselves.  Been trying to use the function "set_but" to solve this, but not sure I'm calling it correct nor setting up the passing of vars to it right.

The purpose of this file, is to read in an Excel file (thus TBS Excel class) and then write data to another Excel file.  Right now, I'm using MySQL to hold the R:C mapping between the files and have not yet set up any MySQL queries, until I can the button to perform their various functions.

Buttons are:
  • Browse - From built in <input type=file> field,
  • View Input File - Uses TBS Excel Class to open originating file,
  • Process - Scrapes the data from file1 into file2,
  • View Output File - Process file, if not already done and opens target file with TBS Excel Class,
  • Print Output - Process file, if not already done and print out the resulting target file.

Right now all the buttons, other than "Browse" are just opening the originating file.

Kinda new on the PHP side, so still feeling my way.

All help appreciated!

Thanks!

OMR

Logged

thorpe

  • Administrator
  • **********
  • Offline Offline
  • Gender: Male
  • Posts: 14,987
    • View Profile
    • WWW
Re: Button Control
« Reply #1 on: January 04, 2008, 12:20:05 AM »
PHP (unlike Javascript) runs server side, therefore you cannot call a php function directly with a client side action.

You seam to be confusing server side code with client side code. PHP is unlike Javascript which does run on the client (browser).
Logged

Currently reading Learning the Bash shell (again).
Debian :: Hudzilla :: Rute :: Howto Ask? :: My Blog :: My Git Repos

OldManRiver

  • Member
  • Offline Offline
  • Posts: 56
    • View Profile
Re: Button Control
« Reply #2 on: January 05, 2008, 02:14:49 PM »
All,

Resolved with this code:
Code: [Select]
<?php
   define
('TITLE1''Main Title');
   
define('TITLE2''Subtitle');
   
define('ORGFIL''source.xls');
   
define('ORGSHT''sheet1');
   
define('OCLROW''5 324');
   
define('TRGFIL''target.xls');
   
define('TRGSHT''sheet2');
   
define('TCLROW''11 57');
   include(
'Zips/TBS Excel/tbs_class.php');          //Load TBS Class
   
include('Zips/TBS Excel/tbs_plugin_excel.php');   //Load TBS plugin

   
function open_xcel($myfile,$mysheet) {
      
$opn_str $myfile;
      
$TBS = new clsTinyButStrong;
      
$TBS->PlugIn(TBS_INSTALL,TBS_EXCEL);
      
$TBS->LoadTemplate($myfile);
//      $TBS->MergeBlock('book',$books);               //Process Alternate Cell Mapping
//      $TBS->MergeBlock('tsk1,tsk2',$tasks);          //Process Alternate Cell Mapping
//      $TBS->MergeBlock('emp',$employees);            //Process Alternate Cell Mapping
      
$TBS->PlugIn(TBS_EXCEL,TBS_EXCEL_FILENAME,'result.xls');
      
$TBS->Show();
   }

   
$but_vin '<button type=submit name=iview onclick="value=\'invw\'">'.
              
'View Input File</button>';
   
$but_vot '<button type=submit name=oview onclick="value=\'outv\'">'.
              
'View Output File</button>';
   
$but_prc '<button type=submit name=proc onclick="value=\'proc\'">'.
              
'Process</button>';
   
$but_prt '<button type=submit name=prnt onclick="value=\'prnt\'">'.
              
'Print Output</button>';
   
$two_spc '&nbsp;&nbsp;';
   
$but_lin $but_prc.$two_spc.$but_vot.$two_spc.$but_prt;
   
$vot_val '"D:\Local Files\Company Relations, Projects & Bids\Active\Avid Business Networks\avid phone quote.xls"';

   
$vin_val $HTTP_POST_VARS['infil'];
   
$fld_vin "<input type=file size=80 name=infil value=$vin_val ".
              
"onclick=\"document.forms['scrub'].submit();\">";
   
$fld_vot "<input type=text size=100 name=otfil value=$vot_val>";
   
$vot_val 'D:\Local Files\Company Relations, Projects & '.
              
'Bids\Active\Avid Business Networks\avid phone quote.xls';
   if (
$HTTP_POST_VARS['iview']=='invw') {
      
$tstbut $HTTP_POST_VARS['iview'];
   }
   if (
$HTTP_POST_VARS['oview'] == 'outv') {
      
$tstbut $HTTP_POST_VARS['oview'];
   }
   if (
$HTTP_POST_VARS['proc']=='proc') {
      
$tstbut $HTTP_POST_VARS['proc'];
   }
   if (
$HTTP_POST_VARS['prnt']=='prnt') {
      
$tstbut $HTTP_POST_VARS['prnt'];
   }unset (
$HTTP_POST_VARS['proc'],$HTTP_POST_VARS['form'],
            
$HTTP_POST_VARS['iview'],$HTTP_POST_VARS['oview'],
            
$HTTP_POST_VARS['prnt']);
   switch (
$tstbut) {
      case 
'invw':   // Open/Edit the INPUT file.
         
if ($HTTP_POST_VARS['infil'] != "") {
            
$vin_val $HTTP_POST_VARS['infil'];
            
$vin_val realpath($vin_val);
            if (
file_exists($vin_val)) {
               
$rc open_xcel($vin_valORGSHT);
            } else {
               echo 
"File => $vin_val <= not found! <br>";
            }
         } else {
            echo 
"Must select a file to procces or read!";
         }
         break;
      case 
'outv':   // Open/Edit the OUTPUT file.
         
if ($HTTP_POST_VARS['otfil'] != "") {
            if (
file_exists($vot_val)) {
               if (
$PROCD == 'Processed') {
                  
$rc open_xcel($vot_valORGSHT);
               } else {
                  echo 
"No OUTPUT File Processed <br>";
               }
            } else {
               echo 
"File => $vot_val <= not found! <br>";
            }
         }
         break;
      case 
'proc':   // Dump the INPUT file into the OUTPUT file.
         
if ($HTTP_POST_VARS['infil'] != "") {
            
$vin_val $HTTP_POST_VARS['infil'];
            
$vin_val realpath($vin_val);
            if (
file_exists($vin_val)) {
               if (
$PROCD != 'Processed') {
//                  $rc = XL_proc($vin_val,$vot_val);
               
} else {
                  echo 
"File already Processed <br>";
               }
            } else {
               echo 
"File => $vot_val <= not found! <br>";
            }
         } else {
            echo 
"Must select a file to procces or read!";
         }
         break;
      case 
'prnt':
         if (
$HTTP_POST_VARS['otfil'] != "") {
            if (
file_exists($vot_val)) {
//               $rc = open_xcel($vot_val, ORGSHT);
            
} else {
               echo 
"File => $vot_val <= not found! <br>";
            }
         }
         break;
   }
   
$TIT1 TITLE1;
   
$TIT2 TITLE2;
   
ob_start();
?>


<html>
<head>
<title>Excel Scrub Processor</title>
</head>

<body>
<FORM name="scrub" METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>">
<table width='80%' border=0 align=center>
   <tr height=50>
   <td align=center>&nbsp;</td>
   </tr>

   <tr>
   <td align=center>
   <table width='100%' border=0 align=center bgcolor='#55aaee'>
      <tr>
      <td colspan=4 align=center>&nbsp;</td>
      </tr>

      <tr>
      <td colspan=4 align=center>
          <h1><?php echo $TIT1?></h1>
          <b><?php echo $TIT2?></b>
      </td>
      </tr>

      <tr>
      <td width=25>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td width=25>&nbsp;</td>
      </tr>

      <tr>
      <td>&nbsp;</td>
      <td>
        <?php echo $fld_vin?>
      </td>
      <td align=left width=100>
      <button type=submit name='iview' onclick="value='invw'">View Input File</button>
      </td>
      <td>&nbsp;</td>
      </tr>

      <tr>
      <td>&nbsp;</td>
      <td colspan=2>
        <?php echo $fld_vot?>&nbsp;<b><= Output file</b>
      </td>
      <td>&nbsp;</td>
      </tr>

      <tr>
      <td colspan=4>&nbsp;</td>
      </tr>

      <tr>
      <td colspan=4 align=center>
        <?php echo $but_lin?>
      </td>
      </tr>

      <tr>
      <td colspan=4>&nbsp;</td>
      </tr>
   </table>
   </tr>
</table>
</form>
</body>
</html>
<?php
   ob_end_flush
();
?>
Button processing now working but functions are still in progress.

Thanks all!

OMR

Logged
 

Page created in 0.063 seconds with 17 queries.