0

I have a question of dynamic elements in php loaded through mysql. The PHP code is as follow

<?php 
        $query = "SELECT * FROM `fee_table` WHERE fee_class_id = 6 ";
        $result = mysql_query($query) or die(mysql_error());

        // Print out the contents of the entry
        echo "<table width='400'>";
            echo "<th width='10' scope='col'>Qty</th>";
            echo "<th width='265' scope='col'>Type of Fixture or Item</th>";
            echo "<th width='25' scope='col'>Fee</th>";
            echo "<th width='100' scope='col'>Total</th>";
        while($row = mysql_fetch_assoc($result)){
         $array[] = $row['fee_amount']; 
         $feeKeys = array_values($array);  
              echo "<tr>";
              echo "<td><input size='5'type='text' on='cal_electic_permit()' id=";echo $row['fee_desc'];"   />";
              echo "</td>";
              echo "<td>";
              echo $row['fee_desc'];
              echo "</td>";
              echo "<td>";
              echo $row['fee_amount'];
              echo "</td>";
              echo "<td><input name='electric_fee' type='text' id='electric_fee' size='11' />";
              echo "</td>";
              echo "</tr>";
        }
        echo "</table>";


        //$recfee =$array[0];
        //print($recfee);
        //print_r($array);
        foreach($array as $fee){

        }   //makes counting variable and assigns array value to it
        for ($i =1; $i <= mysql_num_rows($result);$i++){
            echo ${"qty_{$i}"}=$fee;
            echo '<br/>';    
        }

        ?>
  The js code is to get the element id and then calculate the cost of each row on the table.  The problem that I am haveing is getting the js element to work.


        <script type="text/javascript">
                function cal_electic_permit()
                {
                    numRec = eval(document.permit.Receptacles.value)
                    recfee = eval(document.permit.qty_1.value)
                    //cost for commerical new construction permits
                    var recTfee =numRec * recfee;//get value of the fee from php database query

                    document.electric_fee.value = recTfee;

                }

            </script>

THe problem I believe is that the php html element to call the js function is not working right.
I welcome anyone imput.
Jon

5
Contributors
10
Replies
11
Views
4 Years
Discussion Span
Last Post by tokick4
Featured Replies
  • **@tokick4** >THe problem I believe is that the php html element to call the js function is not working right. When you run the code is there an error? At least? Read More

  • >Because I need it to cal upon entering the quanty in each element and figure the total. Do you have the calucation in hand? For example: 2 + 2 then - 1 then add sale tax? Do you understand? If you don't know the calculation then it will be hard … Read More

  • >I have th calculation for the price it is the quanity that must be filled out by the user.for instance ___qty. X $.20 per = price, then sub total the price to have total price. Is it possible to do in php with out refreshing the screen. I did not … Read More

2

@tokick4

THe problem I believe is that the php html element to call the js function is not working right.

When you run the code is there an error? At least?

Edited by LastMitch: grammer

0

In 15 line your code, you assigned attribute "on" the function by name "cal_electic_permit"?
What is this attribute? Maybe, you keep in mind event "onload".

0

radow it was onkeyup but it would not work so took it out and starte the onclick and realized that that would not work either so i forgot about it. Any Ideas or am I on the right track.

LastMitch I dont get any errors it just does not do any calc.

0

Because I need it to cal upon entering the quanty in each element and figure the total.

3

Because I need it to cal upon entering the quanty in each element and figure the total.

Do you have the calucation in hand?

For example: 2 + 2 then - 1 then add sale tax?

Do you understand? If you don't know the calculation then it will be hard for anyone to calculate the math in PHP like what Squidge said

Edited by LastMitch: grammer

0

I have th calculation for the price it is the quanity that must be filled out by the user.
for instance ___qty. X $.20 per = price, then sub total the price to have total price. Is it possible to do in php with out refreshing the screen. I did not think it was. That way I was using JS or jq.

4

I have th calculation for the price it is the quanity that must be filled out by the user.for instance ___qty. X $.20 per = price, then sub total the price to have total price. Is it possible to do in php with out refreshing the screen. I did not think it was. That way I was using JS or jq.

What do you mean refreshing the screen? So far base on your code you don't have a calculation. Is this a check out sheet?

0

Is this all the code for the page? If so, there are a lot of issues with this code that need to be addressed.

echo "<td><input size='5'type='text' on='cal_electic_permit()' id=";echo $row['fee_desc'];" />";

You're missing an echo for the " />";.

numRec = eval(document.permit.Receptacles.value)
recfee = eval(document.permit.qty_1.value)
document.electric_fee.value = recTfee;

What is document.permit? What is document.electric_fee? I don't see "permit" anywhere in the code except on these lines and in the function name. electric_fee at least appears as the id for an input field, but if you want to grab this for use in the javascript what you need is document.getElementById('electric_fee').value = .... You can't simply refer to elements by their name, you need to use the right function to grab the object.

You can indeed use JS to perform the calculation without a page refresh. You can also use PHP, but this would require using AJAX.

As others have mentioned above, you need to clarify what you're trying to accomplish. As it stands, it's not clear what items you wish to perform operations on (are you trying to use fee_desc and fee_amount for the calculation?), and the way you seem to be going about it is incorrect. Also, what event needs to occur in order to trigger the calculation?

0

Sorry here is the full code for the page. I did not post it because it is so long. I am going to get reed of the duplicate codes. I realy appreaciate all the help from everyone here.

<?php 
include 'init.php';
 require_once('Connections/cdocsconnect.php');

$employee_page_authorized = 7;
$user_page = user_page();
//echo $user_page; to test what number is returned from the database
if($user_page == $employee_page_authorized)
{   
    if (logged_in())
    {
        include 'template/header.php';
?>
<?php

$project_id = $_GET['project_id'];

if (!function_exists("GetSQLValueString")) 
{
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
if (PHP_VERSION < 6) 
{
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
 }
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "permit")) {
  $insertSQL = sprintf("INSERT INTO permit (master_permit, class_of_permit, tmsID, date_issued, valuation, planRevFee, permitFee, total_fee, description_of_work, sqft, no_of_buildings, dewelling_units, no_bedrm, no_baths, id_customer, id_architect, id_contractor, project_name, PropNum, PropStName, PropCity, PropSt, id_flood, type_of_work, id_zoning, id_type_of_construction, id_occupancy, sprinkled, Code_Book_ID, contactName, contactNumber, contactFax, last_modified, project_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,now(), '$project_id')",

                       GetSQLValueString($_POST['masterPermit'], "text"),
                       GetSQLValueString($_POST['class_of_permit'], "int"),
                       GetSQLValueString($_POST['tmsID'], "int"),
                       GetSQLValueString($_POST['date_issued'], "date"),
                       GetSQLValueString($_POST['valuation'], "double"),
                       GetSQLValueString($_POST['planRevFee'], "double"),
                       GetSQLValueString($_POST['permitFee'], "double"),
                       GetSQLValueString($_POST['total_fee'], "double"),
                       GetSQLValueString($_POST['desciptionWork'], "text"),
                       GetSQLValueString($_POST['sqft'], "int"),
                       GetSQLValueString($_POST['no_of_buildings'], "double"),
                       GetSQLValueString($_POST['dewelling_units'], "double"),
                       GetSQLValueString($_POST['no_bedrm'], "int"),
                       GetSQLValueString($_POST['no_baths'], "int"),
                       GetSQLValueString($_POST['id_customer'], "int"),
                       GetSQLValueString($_POST['id_architect'], "int"),
                       GetSQLValueString($_POST['id_contractor'], "int"),
                       GetSQLValueString($_POST['project_name'], "text"),
                       GetSQLValueString($_POST['PropNum'], "text"),
                       GetSQLValueString($_POST['PropStName'], "text"),
                       GetSQLValueString($_POST['PropCity'], "text"),
                       GetSQLValueString($_POST['PropSt'], "text"),
                       GetSQLValueString($_POST['id_flood'], "int"),
                       GetSQLValueString($_POST['type_of_work'], "int"),
                       GetSQLValueString($_POST['id_zoning'], "int"),
                       GetSQLValueString($_POST['id_type_of_construction'], "int"),
                       GetSQLValueString($_POST['id_occupancy'], "int"),
                       GetSQLValueString($_POST['Sprinkled'], "text"),
                       GetSQLValueString($_POST['codeType'], "int"),
                       GetSQLValueString($_POST['contactName'], "text"),
                       GetSQLValueString($_POST['contactNumber'], "text"),
                       GetSQLValueString($_POST['contactFax'], "text"))or die(mysql_error());

  mysql_select_db($database_cdocsconnect, $cdocsconnect);
  $Result1 = mysql_query($insertSQL, $cdocsconnect) or die(mysql_error());

  $insertGoTo = "indextemp.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <link href="css/style.css" rel="stylesheet " type="text/css" />
            <style type="text/css">
            #wrapper #content #permit .propInfo #TMS {
                font-weight: bold;
                float: left;
            }
            </style>
            <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
            <script type="text/javascript" src="js/jquery-ui-1.8.20.custom.min.js"></script>
            <script type="text/javascript">
            // JavaScript Document
            $(document).ready(function propSearch(){

                id = <?php echo $_SESSION['TMS']?>;
                $.getJSON('jsonsearch/searchresultOwnerProp.php', {term : id}, function(data){
                $.each(data, function (n,value){
                    $('input#propNum').val(data[0]['STNUM']);
                    $('input#propStName').val(data[0]['STNAM']);
                    $('#TMS').html(data[0]['TMS']);
                    $('input#tmsID').val(data[0]['tms_id']);
                    $('#propOwnerName').html(data[0]['ONAME']);
                    $('#propOwnerAddress').html(data[0]['MADD']);
                    $('#propOwnerCity').html(data[0]['CITY']);
                    $('#propOwnerState').html(data[0]['STATE']);
                    $('#propOwnerZip').html(data[0]['ZIP']);
                    $('#ownerSubdivision').html(data[0]['SUBD']);
                    $('#usecd').html(data[0]['USECD']);
                    $('#MADD').html(data[0]['STNUM'] + "  "+data[0]['STNAM']);
                    //$('#MADD2').html(data[0]['STNAM']);
                    $('#lotno').html(data[0]['LEGAL']);
                    $('#dist').html(data[0]['DIST']);   
                  });
                });
            });
 <!-- ---------------------------------------------End of Search script for Owner ----------------------------------------- --> 

            </script>
            <script type="text/javascript">
            // JavaScript Document
            $(document).ready(function cust(){

                id = <?php echo $_SESSION['id_customer']?>;
                $.getJSON('jsonsearch/searchresult.php', {term : id}, function(data){
                $.each(data, function(n, value){

                $('#fname').html(data[0]['first_name'] +" "+ data[0]['middle_name'] +" "+ data[0]['last_name']);
                $('#id_customer').val(data [0]['contact_id']);
                $('#companyname').html(data[0]['company_name']);
                $('#CustomerAddress').html(data[0]['address']);
                $('#CustomerCity').html(data[0]['city']);
                $('#CustomerState').html(data[0]['state']);
                $('#CustomerZip').html(data[0]['zip']);
                $('#CustomerPhone').html(data[0]['home_number']);
                $('#CustomerCell').html(data[0]['cell_number']);
                $('#CustomerEmail').html(data[0]['email']);
                });
              });
             });
 <!-- End of Search script for Lessess ----------------------------------------------------------------------------------- -->

            </script>
            <script type="text/javascript">
            // JavaScript Document
            $(document).ready(function contractor(){

                    $id=<?php echo $_SESSION['id_contractor']?>;
                    $.getJSON('jsonsearch/contractorsearchresult.php', {term :$id }, function(data){
                    $.each(data, function(n, value){

                    $('input#id_contractor').val(data[0]['contact_id']);        
                    $('#ContractorFirstName').html(data[0]['first_name']);                  
                    $('#ContractorMiddleName').html(data[0]['middle_name']);
                    $('#ContractorLastName').html(data[0]['last_name']);
                    $('#ContractorCompanyName').html(data[0]['company_name']);
                    $('#ContractorAddress').html(data[0]['address']);
                    $('#ContractorCity').html(data[0]['city']);
                    $('#ContractorState').html(data[0]['state']);
                    $('#ContractorZip').html(data[0]['zip']);
                    $('#ContractorPhone').html(data[0]['business_number']);
                    $('#ContractorFax').html(data[0]['fax']);
                    $('#ContractorCell').html(data[0]['cell_number']);
                    $('#ContractorEmail').html(data[0]['email']);
                    $('#Contractorst_lic_nu').html(data[0]['state_lic_no']);
                    $('#Contractor_st_lic_exp').html(data[0]['state_exp_date']);
                    $('#Contractorcity_lic_no').html(data[0]['county_city_lic_no']);
                    $('#ContractorCCExp').html(data[0]['county_city_exp_date']);
                });
            });     
        });

<!-- --------------------------------------------End of Search script for Contractor------------------------------------- -->
            </script>

            <script type="text/javascript">
                // JavaScript Document
                $(document).ready(function architect(){

                    id = <?php echo $_SESSION['id_architect']?>;
                    $.getJSON('jsonsearch/architecsearchresult.php', {term : id}, function(data){
                    $.each(data,function (n,value){
                        $('#id_architect').val(data[0]['contact_id']);
                        $('#ArchitectFirstName').html(data[0]['first_name']);
                        $('#ArchitectMiddleName').html(data[0]['middle_name']);
                        $('#ArchitectLastName').html(data[0]['last_name']);
                        $('#ArchitectCompany').html(data[0]['company_name']);
                        $('#ArchitectAddress').html(data[0]['address']);
                        $('#ArchitectCity').html(data[0]['city']);
                        $('#ArchitectState').html(data[0]['state']);
                        $('#ArchitectZip').html(data[0]['zip']);
                        $('#ArchitectPhone').html(data[0]['business_number']);
                        $('#ArchitectCell').html(data[0]['cell_number']);
                        $('#ArchitectEmail').html(data[0]['email']);
                        $('#Architect_lic_nu').html(data[0]['state_lic_no']);
                        $('#ArchitectStateExpDate').html(data[0]['state_exp_date']);
                        $('#Architectcity_lic_no').html(data[0]['county_city_lic_no']);
                        $('#ArchitectCCExpDate').html(data[0]['county_city_exp_date']);
                    });
                });
            });
<!-- End of Search script for Architect/Engineer----------------------------------------------------------------------------- -->


            </script>

            <script type="text/javascript">
                function Cal()
                {
                    CommericalSF = eval(document.permit.sqft.value)
                    //cost for commerical new construction permits
                    //get value of the fee from php database query
                    var valuePermit = CommericalSF*fee;
                    var CostPermitFee = valuePermit;
                    var reviewFee = valuePermit*.5;
                    //var permitFee=25.00;
                    totalfee= valuePermit + reviewFee;
                    document.permit.planRevFee.value = reviewFee
                    document.permit.permitFee.value = valuePermit;
                    document.permit.total_fee.value = totalfee;
                    //document.write("Gas Permit Fees is $" +totalfee)
                    //('#result').html("Gas Permit price is $" + totalfee).show(); does not work

                }

            </script>
            <Script type="text/javascript">
                    function hide_searchContractor()
                    {
                        $(document).ready(function()
                            {
                                var tp = document.getElementById('typePermit').selectedIndex;
                                <!--document.write(tp);-->
                                if(tp==1)
                                {
                                    //$('.main_contractor').hide();
                                    //$('.searchContractor').show();
                                    $('#contractorsearch').show();
                                    $('input#ContractorId').html('');
                                    $('#ContractorFirstName').html('');
                                    $('#ContractorMiddleName').html('');
                                    $('#ContractorLastName').html('');
                                    $('#ContractorCompanyName').html('');
                                    $('#ContractorAddress').html('');
                                    $('#ContractorCity').html('');
                                    $('#ContractorState').html('');
                                    $('#ContractorZip').html('');
                                    $('#ContractorPhone').html('');
                                    $('#ContractorCell').html('');
                                    $('#ContractorEmail').html('');
                                    $('#Contractorst_lic_nu').html('');
                                    $('#Contractor_st_lic_exp').html('');
                                    $('#Contractorcity_lic_no').html('');
                                    $('#ContractorCCExp').html('');
                                    $('#architectSearch').show();
                                    $('#ArchitectFirstName').html('');
                                    $('#ArchitectMiddleName').html('');
                                    $('#ArchitectLastName').html('');
                                    $('#ArchitectCompany').html('');
                                    $('#ArchitectAddress').html('');
                                    $('#ArchitectCity').html('');
                                    $('#ArchitectState').html('');
                                    $('#ArchitectZip').html('');
                                    $('#ArchitectPhone').html('');
                                    $('#ArchitectCell').html('');
                                    $('#ArchitectEmail').html('');
                                    $('#Architect_lic_nu').html('');
                                    $('#Architectcity_lic_no').html('');
                                    $('#ArchitectStateExpDate').html('');
                                    $('#ArchitectCCExpDate').html('');
                                }
                                else if(tp==6)
                                {
                                    $('.Permit_Details').hide();
                                    $('.EPF').show();
                                }
                            });
                    };
            </script>
            <script type="text/javascript">
            function hide_main()
                    {
                        $(document).ready(function()
                            {
                                var tp = document.getElementById('typePermit').selectedIndex;
                                <!--document.write(tp);-->
                                if(tp==0)
                                {
                                    $('#contractorsearch').hide();
                                    $('#architectSearch').hide();
                                    $('.PPF').hide();
                                }
                            });
                    }
                                </script>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Dashboard</title>
            </head>

            <body onload="hide_main();">
<p></p>
<div id="wrapper">
  <div id="leftcol">
    <?php include 'leftsidemenu.php';?>
  </div>
  <div id="content">Search for Each to fill in form automatically:<br />
    <?php echo 'PROJECT ID:  ',$project_id; 
                    echo '     CONTRACTOR ID:  ',$_SESSION['id_contractor'],'',$_SESSION['project_name'];
              ?><br />
    ELECTRICAL PERMIT APPLICATION:<br />
    Type of Permit:
    <select id="typePermit" name="class_of_permit" class="customerInfo" onchange="hide_searchContractor()" >
      <?php
                                        do {  
                                        ?>
      <option value="<?php echo $row_typeofPermit['id_permit_classification']?>" ><?php echo $row_typeofPermit['description_of_class']?></option>
      <?php
                                            } while ($row_typeofPermit = mysql_fetch_assoc($typeofPermit));
                                              $rows = mysql_num_rows($typeofPermit);
                                              if($rows > 0) {
                                                  mysql_data_seek($typeofPermit, 0);
                                                  $row_typeofPermit = mysql_fetch_assoc($typeofPermit);
                                              }
                                              //this is to hide the main_contractor div by using a function
                                              if($row_typeofPermit['id_permit_classification']=='0'){?>
                                                <?php
                                              }else{

                                                ?>
    </select>
    <br />
    Every thing in RED must be filled in
    <div id="my">remove me</div>
    <form action="<?php echo $editFormAction; ?>" method="POST" name="permit" id="permit">
      <p>&nbsp;</p>
      <hr />
      <div class="propInfo">
        <table width="850">
          <tr>
            <td>Project Name:</td>
            <td><input name="project_name" type="text" class="customerInfo" value="<?php echo $_SESSION['project_name'];?>" size="40"  style="background-color:#FF7D7D"/></td>
            <td>Property Address:</td>
            <td><input name="PropNum" type="text" id="propNum" style="background-color:#FF7D7D" value="<?php echo $_SESSION['propStNum'];?>" size="6"/></td>
            <td><input name="PropStName" type="text" id="propStName" style="background-color:#FF7D7D" value="<?php echo $_SESSION['propStName'];?>" size="30" /></td>
            <td><input name="PropCity" type="text"  id="propCity" value="Myrtle Beach" size="20" style="background-color:#FF7D7D" /></td>
            <td><input name="PropSt" type="text"  id="propSt" value="SC" size="6"  style="background-color:#FF7D7D"/></td>
          </tr>
        </table>
        <table width="850">
          <tr>
            <td width="351"><?php 
                if($_SESSION['project_type'] == 'R'){?>
              <input type="radio" name="masterPermit" value="B" checked="checked" id="masterPermit" />
              <label>Residential</label>
              <?php  
                }else{?>
              <input type="radio" name="masterPermit" value="BC" checked="checked" id="masterPermit" />
              <label>Commercial</label>
              <?php
                }
                ?>
              &#160;&#160; </td>
            <td width="77">Date Issued:</td>
            <td width="259"><input name="date_issued" type="text" class="customerInfo" value="<?php echo date('Y-m-d');?>" size="10" />
              (ex.2012-01-31) Flood Zone: </td>
            <td width="143"><select style="background-color:#FF7D7D" name="id_flood" class="customerInfo">
              <?php do{?>
              <option value="<?php echo $row_floodzone['idflood_zone']?>" selected="selected" ><?php echo $row_floodzone['flood_zone']?></option>
              <?php
                                            } while ($row_floodzone = mysql_fetch_assoc($floodzone));
                                            ?>
            </select></td>
          </tr>
        </table>
        <table width="850">
          <tr>
            <td width="87"><input type="hidden" name="tmsID" id="tmsID" />
              Tax Map:&#160;</td>
            <td width="153"><div id="TMS"></div></td>
            <td width="100">Legal Address:</td>
            <td width="490"><div id="MADD"></div></td>
          </tr>
        </table>
        <table width="850">
          <tr>
            <td width="55">Lot No.</td>
            <td width="172"><div id="lotno"></div></td>
            <td width="46">District:</td>
            <td width="132"><div id="dist"></div></td>
            <td width="131">Subdivision/Complex:</td>
            <td width="286"><div id="ownerSubdivision"></div></td>
          </tr>
        </table>
      </div>
      <hr />
      <div id="custInfo">
        <table width="700">
          <tr>
            <td width="82" height="21" align="left" nowrap="nowrap"><input name="id_customer" type="hidden" id="id_customer" />
              Customer:<br /></td>
            <th width="130" align="left"><div id="fname"></div></th>
            <th width="122">&nbsp;</th>
            <td width="124" align="left">Company Name: </td>
            <th width="218"><div id="compnayname"></div></th>
          </tr>
        </table>
        <tr>
          <td height="21" align="right" nowrap="nowrap"></td>
          <td colspan="4"><table width="700" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="9%" align="left" valign="top" scope="col">Address:</td>
              <th width="21%" align="left" scope="col"><div id="CustomerAddress"></div></th>
              <td width="5%" align="left" valign="top" scope="col">City:</td>
              <th width="27%" align="left" scope="col"><div id="CustomerCity"></div></th>
              <td width="6%" valign="top" scope="col">State:</td>
              <th width="12%" align="left" scope="col"><div id="CustomerState"></div></th>
              <td width="5%" align="left" valign="top" scope="col">Zip:</td>
              <th width="15%" align="left" scope="col"><div id="CustomerZip"></div></th>
            </tr>
          </table>
            <table width="700" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" align="left" scope="col">Phone:</td>
                <th width="19%" align="left" scope="col"><div id="CustomerPhone"></div></th>
                <td width="4%" align="left" scope="col">Cell:</td>
                <th width="17%" align="left" scope="col"><div id="CustomerCell"></div></th>
                <td width="6%" align="left" scope="col">E-mail:</td>
                <th width="48%" align="left" scope="col"><div id="CustomerEmail"></div></th>
              </tr>
            </table></td>
        </tr>
      </div>
      <hr />
      <div class="main_contractor">       
        <input name="contractorsearch" type="text" id="contractorsearch" value="" size="15" style="background-color:#CF3"/><label>Change Contractors</label>
        <div id="contractorList"></div>        
        <table width="700">
          <tr>
            <td colspan="4" valign="top"><table width="700" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="14%" height="19" align="left" valign="top" scope="col"><input type="hidden" name="id_contractor" id="id_contractor"value="" />
                  Contractor:</td>

                <th width="27%" align="left" scope="col"><div id="ContractorCompanyName">
                  <p id="ContractorCompanyName">&nbsp;</p>
                </div></th>
                <td width="15%" align="left" valign="top" scope="col">Contact Name:</td>
                <th width="16%" align="left" valign="top" scope="col"><div id="ContractorFirstName"></div></th>
                <th width="28%" align="left" valign="top" scope="col"><div id="ContractorLastName">
                  <div id="ContractorMiddleName"></div>
                </div></th>
              </tr>
            </table>
              <table width="74%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="9%" align="left" valign="top" scope="col">Address:</td>
                  <th width="21%" align="left" scope="col"><div id="ContractorAddress"></div></th>
                  <td width="5%" align="left" valign="top" scope="col">City:</td>
                  <th width="27%" align="left" scope="col"><div id="ContractorCity"></div></th>
                  <td width="6%" valign="top" scope="col">State:</td>
                  <th width="12%" align="left" scope="col"><div id="ContractorState"></div></th>
                  <td width="5%" align="left" valign="top" scope="col">Zip:</td>
                  <th width="15%" align="left" scope="col"><div id="ContractorZip"></div></th>
                </tr>
              </table>
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="6%" align="left" scope="col">Phone:</td>
                  <th width="19%" align="left" scope="col"><div id="ContractorPhone"></div></th>
                  <td width="4%" align="left" scope="col">Cell:</td>
                  <th width="17%" align="left" scope="col"><div id="ContractorCell"></div></th>
                  <td width="6%" align="left" scope="col">E-mail:</td>
                  <th width="48%" align="left" scope="col"><div id="ContractorEmail"></div></th>
                </tr>
              </table>
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="9%" align="left" scope="col">State Lic:</td>
                  <th width="19%" align="left" scope="col"><div id="Contractorst_lic_nu"></div></th>
                  <td width="11%" align="left" scope="col">Exp. Date:</td>
                  <th width="14%" align="left" scope="col"><div id="Contractor_st_lic_exp"></div></th>
                  <td width="15%" align="left" scope="col">City/County Lic:</td>
                  <th width="10%" scope="col"><div id="Contractorcity_lic_no"></div></th>
                  <td width="10%" align="left" scope="col">Exp. Date:</td>
                  <th width="12%" align="left" scope="col"><div id="ContractorCCExp"></div></th>
                </tr>
              </table></td>
          </tr>
        </table>
        <script type="text/javascript">
            // JavaScript Document

            $(function contractor(){
                $('#contractorList').hide();
              $('input#contractorsearch').autocomplete({
                    source: 'jsonsearch/contractorsearchsuggestion.php',
                    select: listContractor,
                    minLength: 1
                });

              $('#contractorButton').click(listContractor);
            });

            listContractor = function contractor(){
                $('#contractorList').show();
                // Clear the output text boxes
                $('input#ContractorId').val('');
                $('input#ContractorFirstName').val('');
                $('input#ContractorMiddleName').val('');
                $('input#ContractorLastName').val('');
                $('input#ContractorCompanyName').val('');
                $('input#ContractorAddress').val('');
                $('input#ContractorCity').val('');
                $('input#ContractorState').val('');
                $('input#ContractorZip').val('');
                $('input#ContractorPhone').val('');
                $('input#ContractorCell').val('');
                $('input#ContractorEmail').val('');
                $('input#st_lic_nu').val('');
                $('input#city_lic_no').val('');
                $('input#Contractor_st_lic_exp').val('');
                $('input#Contractorcity_lic_no').val('');
                $('input#ContractorCCExp').val('');

                var term = $('input#contractorsearch').val();
                $.getJSON('jsonsearch/contractorsearchlist.php', {term : term},function(data){
                    custIDs = new Array();

                $('#contractorList').html('<b>Click on the names to change contractors:</b><ol></ol>');
                $.each(data, function(n, value){
                    custIDs.push(value['contact_id']);

                $('#contractorList > ol').append('<li class="custList" id="' + value['contact_id'] + '"><b><u>' + value['company_name'] + '</u></b>,' + value['first_name'] + ',' + value['middle_name'] + ',' + value['last_name'] + '</li>');
                $('input#contractorsearch').val('');
                });

                $.each(custIDs, function(n, value){
                $('#contractorList > ol > li#' + value).click(function(){
                id = $('#contractorList > ol > li#' + value).attr('id');
                $.getJSON('jsonsearch/contractorsearchresult.php', {term : id}, function(data){
                    $('#contractorList').hide();
                    $('#contractorsearch').hide();
                    $('#id_contractor').val(data[0]['contact_id']);     
                    $('#ContractorFirstName').html(data[0]['first_name']);                  
                    $('#ContractorMiddleName').html(data[0]['middle_name']);
                    $('#ContractorLastName').html(data[0]['last_name']);
                    $('#ContractorCompanyName').html(data[0]['company_name']);
                    $('#ContractorAddress').html(data[0]['address']);
                    $('#ContractorCity').html(data[0]['city']);
                    $('#ContractorState').html(data[0]['state']);
                    $('#ContractorZip').html(data[0]['zip']);
                    $('#ContractorPhone').html(data[0]['business_number']);
                    $('#ContractorFax').html(data[0]['fax']);
                    $('#ContractorCell').html(data[0]['cell_number']);
                    $('#ContractorEmail').html(data[0]['email']);
                    $('#Contractorst_lic_nu').html(data[0]['state_lic_no']);
                    $('#Contractor_st_lic_exp').html(data[0]['state_exp_date']);
                    $('#Contractorcity_lic_no').html(data[0]['county_city_lic_no']);
                    $('#ContractorCCExp').html(data[0]['county_city_exp_date']);
                    });
                   });
                  });
                });

            return false;
            };

<!-- --------------------------------------------End of Search script for Contractor------------------------------------- -->
            </script>
      </div>
      <hr />
      <!-------------------------------------------contractor----------------------------------------------------->

        <input name="architectSearch" type="text" id="architectSearch" size="15"style="background-color:#CF3"/><label>Change Architect/Engineers</label>><br />
        <div id="architectList"></div>
      <div id="archInfo">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">&nbsp;</td>
          <td colspan="4"><table width="700" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="12%" align="left" valign="top" scope="col"><input type="hidden" name="id_architect" id="id_architect"value="" />
                Architect:</td>
              <th width="29%" align="left" scope="col"><div id="ArchitectCompany"></div></th>
              <td width="14%" align="left" valign="top" scope="col">Contact Name:</td>
              <th width="13%" align="left" valign="top" scope="col"><div id="ArchitectFirstName"></div></th>
              <th width="14%" align="left" valign="top" scope="col"><div id="ArchitectMiddleName"></div></th>
              <th width="18%" align="left" valign="top" scope="col"><div id="ArchitectLastName"></div></th>
            </tr>
          </table>
            <table width="700" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="9%" align="left" valign="top" scope="col">Address:</td>
                <th width="21%" align="left" scope="col"><div id="ArchitectAddress"></div></th>
                <td width="5%" align="left" valign="top" scope="col">City:</td>
                <th width="27%" align="left" scope="col"><div id="ArchitectCity"></div></th>
                <td width="6%" valign="top" scope="col">State:</td>
                <th width="12%" align="left" scope="col"><div id="ArchitectState"></div></th>
                <td width="5%" align="left" valign="top" scope="col">Zip:</td>
                <th width="15%" align="left" scope="col"><div id="ArchitectZip"></div></th>
              </tr>
            </table>
            <table width="700" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" align="left" scope="col">Phone:</td>
                <th width="19%" align="left" scope="col"><div id="ArchitectPhone"></div></th>
                <td width="4%" align="left" scope="col">Cell:</td>
                <th width="17%" align="left" scope="col"><div id="ArchitectCell"></div></th>
                <td width="6%" align="left" scope="col">E-mail:</td>
                <th width="48%" align="left" scope="col"><div id="ArchitectEmail"></div></th>
              </tr>
            </table>
            <table width="700" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="9%" align="left" scope="col">State Lic:</td>
                <th width="19%" align="left" scope="col"><div id="Architect_lic_nu"></div></th>
                <td width="11%" align="left" scope="col">Exp. Date:</td>
                <th width="14%" align="left" scope="col"><div id="ArchitectStateExpDate"></div></th>
                <td width="15%" align="left" scope="col">City/County Lic:</td>
                <th width="10%" scope="col"><div id="Architectcity_lic_no"></div></th>
                <td width="10%" align="left" scope="col">Exp. Date:</td>
                <th width="12%" align="left" scope="col"><div id="ArchitectCCExpDate"></div></th>
              </tr>
            </table></td>
        </tr>
        <script type="text/javascript">
                // JavaScript Document
                $(function architect(){

                    $('#architectList').hide();
                  $('input#architectSearch').autocomplete({
                        source: 'jsonsearch/architecsearchsuggestion.php',
                        select: listarchitect,
                        minLength: 1
                    });

                  $('#architectButton').click(listarchitect);
                });

                listarchitect = function architect(){
                    $('#architectList').show();
                    // Clear the output text boxes
                    $('input#architectFirstNameFirstName').val('');
                    $('input#architectMiddleName').val('');
                    $('input#architectLastName').val('');
                    $('input#architectName').val('');
                    $('input#architectAddress').val('');
                    $('input#architectCity').val('');
                    $('input#architectState').val('');
                    $('input#architectZip').val('');
                    $('input#architectPhone').val('');
                    $('input#architectCell').val('');
                    $('input#architectEmail').val('');
                    $('input#architect_st_lic_no').val('');
                    $('input#architect_city_lic').val('');
                    $('input#state_exp_date').val('');


                    var term = $('input#architectSearch').val();
                    $.getJSON('jsonsearch/architecsearchlist.php', {term : term},function(data){
                            custIDs = new Array();

                            $('#architectList').html('<b>Click on the names to change Architet/Engineers:</b><ol></ol>');
                      $.each(data, function(n, value){
                        custIDs.push(value['contact_id']);

                                $('#architectList > ol').append('<li class="custList" id="' + value['contact_id'] + '"><b><u>' + value['company_name'] + '</u></b>, ' + value['first_name'] + ', ' + value['middle_name'] + ', ' + value['last_name'] + '</li>');
                                $('input#architectSearch').val('');
                            });

                      $.each(custIDs, function(n, value){
                                $('#architectList > ol > li#' + value).click(function(){
                                        id = $('#architectList > ol > li#' + value).attr('id');
                                        $.getJSON('jsonsearch/architecsearchresult.php', {term : id}, function(data){
                                        $('#architectList').hide();
                                        $('#architectSearch').hide();
                                            $('#id_architect').val(data[0]['contact_id']);
                                            $('#ArchitectFirstName').html(data[0]['first_name']);
                                            $('#ArchitectMiddleName').html(data[0]['middle_name']);
                                            $('#ArchitectLastName').html(data[0]['last_name']);
                                            $('#ArchitectCompany').html(data[0]['company_name']);
                                            $('#ArchitectAddress').html(data[0]['address']);
                                            $('#ArchitectCity').html(data[0]['city']);
                                            $('#ArchitectState').html(data[0]['state']);
                                            $('#ArchitectZip').html(data[0]['zip']);
                                            $('#ArchitectPhone').html(data[0]['business_number']);
                                            $('#ArchitectCell').html(data[0]['cell_number']);
                                            $('#ArchitectEmail').html(data[0]['email']);
                                            $('#Architect_lic_nu').html(data[0]['state_lic_no']);
                                            $('#ArchitectStateExpDate').html(data[0]['state_exp_date']);
                                            $('#Architectcity_lic_no').html(data[0]['county_city_lic_no']);
                                            $('#ArchitectCCExpDate').html(data[0]['county_city_exp_date']);
                                            //$('#state_exp_date').append('<li class="custList"'+ value['contact_id']+ value['state_exp_date']+'</li>');
                                        });
                                    });
                            });
                    });

                    return false;
                  };
<!-- End of Search script for Architect/Engineer----------------------------------------------------------------------------- -->

            </script>
      </div>

      <hr />

        <div id="permit_detail" class="Permit_Details">
          <table width="825">
            <tr>
              <td width="139" align="right">Type of Work:</td>
              <td width="157"><select id="type_of_work"style="background-color:#FF7D7D" name="type_of_work" class="customerInfo"  onchange="calPermit();">
                  <?php
                do {  
                  ?>
                  <option value="<?php echo $row_workClassification['idwork_classification']?>"><?php echo $row_workClassification['work_classification']?></option>
                  <?php
                   } while ($row_workClassification = mysql_fetch_assoc($workClassification));
                   $rows = mysql_num_rows($workClassification);
                    if($rows > 0) {
                      mysql_data_seek($workClassification, 0);
                      $row_workClassification = mysql_fetch_assoc($workClassification);
                       }
                      ?>
              </select></td>
              <Script type="text/javascript">// changes the div for calculation of permit cost -------------
                    function calPermit(){
                        $(document).ready(function() {

                                var tw = document.getElementById('type_of_work').selectedIndex;
                                <!--document.write(tp);-->
                                if((tw)==0){
                                $('#valueOfPermit').show();
                                }else{
                                    $('#valueOfPermit').hide();
                                }
                                });
                                }
            </script>
              <td width="174">&nbsp;</td>
              <td width="174">&nbsp;</td>
              <td width="157">Occupancy:
                <select style="background-color:#FF7D7D" name="id_occupancy" class="customerInfo">
                  <?php 
                                                do {  
                                                ?>
                  <option value="<?php echo $row_occupancy['occupancy_id']?>" ><?php echo $row_occupancy['type_of_occupancy']?></option>
                  <?php
                                                } while ($row_occupancy = mysql_fetch_assoc($occupancy));
                                                ?>
                </select></td>
            </tr>
            <tr valign="baseline">
              <td height="29" align="right" nowrap="nowrap">&nbsp;</td>
              <td colspan="2">Sqft:
                <input style="background-color:#FF7D7D" name="sqft" type="text" class="customerInfo" value="" size="6" onchange="Cal();"/>
                Sprinkled:
                <label>
                  <input type="radio" name="Sprinkled" value="0" id="Sprinkled_0" />
                  No</label>
                <label>
                  <input type="radio" name="Sprinkled" value="1" id="Sprinkled_1" />
                  Yes</label></td>
              <td colspan="2">Code Type:
                <label for="codeType"></label>
                <select style="background-color:#FF7D7D"  name="codeType" class="customerInfo" id="codeType">
                  <?php
                                                do {  
                                                ?>
                  <option value="<?php echo $row_rsCodeBook['code_book_id']?>"><?php echo $row_rsCodeBook['description']?></option>
                  <?php
                                                } while ($row_rsCodeBook = mysql_fetch_assoc($rsCodeBook));
                                                  $rows = mysql_num_rows($rsCodeBook);
                                                  if($rows > 0) {
                                                      mysql_data_seek($rsCodeBook, 0);
                                                      $row_rsCodeBook = mysql_fetch_assoc($rsCodeBook);
                                                  }
                                                ?>
                </select></td>
            </tr>
            <tr valign="baseline">
              <td nowrap="nowrap" align="right">&nbsp;</td>
              <td colspan="4">&nbsp;</td
          ></tr>
            <tr valign="baseline">
              <td align="right" valign="top" nowrap="nowrap">Description of work:</td>
              <td colspan="4"><textarea style="background-color:#FF7D7D" name="desciptionWork" cols="100" rows="10" id="desciptionWork"></textarea></td>
            </tr>
          </table>
        </div>           

      <div id="electrical_permit_form" class="EPF"><hr />Electrical Permit Application:
       // Retrieve all the data from the "electic_permit" table
        <?php 
        $query = "SELECT * FROM `fee_table` WHERE fee_class_id = 6 ";
        $result = mysql_query($query) or die(mysql_error());

        // Print out the contents of the entry
        echo "<table width='400'>";
            echo "<th width='10' scope='col'>Qty</th>";
            echo "<th width='265' scope='col'>Type of Fixture or Item</th>";
            echo "<th width='25' scope='col'>Fee</th>";
            echo "<th width='100' scope='col'>Total</th>";
        while($row = mysql_fetch_assoc($result)){
         $array[] = $row['fee_amount']; 
         $feeKeys = array_values($array);  
              echo "<tr>";
              echo "<td><input size='5'type='text' on='cal_electic_permit()' id=";echo $row['fee_desc'];"   />";
              echo "</td>";
              echo "<td>";
              echo $row['fee_desc'];
              echo "</td>";
              echo "<td>";
              echo $row['fee_amount'];
              echo "</td>";
              echo "<td><input name='electric_fee' type='text' id='electric_fee' size='11' />";
              echo "</td>";
              echo "</tr>";
        }
        echo "</table>";


        //$recfee =$array[0];
        //print($recfee);
        //print_r($array);
        foreach($array as $fee){

        }   //makes counting variable and assigns array value to it
        for ($i =1; $i <= mysql_num_rows($result);$i++){
            echo ${"qty_{$i}"}=$fee;
            echo '<br/>';    
        }

        ?>

        <script type="text/javascript">
                function cal_electic_permit()
                {
                    numRec = eval(document.permit.Receptacles.value)
                    recfee = eval(document.permit.qty_1.value)
                    //cost for commerical new construction permits
                    var recTfee =numRec * recfee;//get value of the fee from php database query
                    //var valuePermit = CommericalSF*fee;
                    //var CostPermitFee = valuePermit;
                    //var reviewFee = valuePermit*.5;
                    //var permitFee=25.00;
                    //totalfee= valuePermit + reviewFee;
                    document.electric_fee.value = recTfee;
                    //document.permit.permitFee.value = valuePermit;
                    //document.permit.total_fee.value = totalfee;
                    //document.write("Gas Permit Fees is $" +totalfee)
                    //('#result').html("Gas Permit price is $" + totalfee).show(); does not work

                }

            </script>
        <table width="412">
          <tr>
            <th width="49" scope="col" >Quanty</th>
            <th width="203" scope="col">Type of Fixtuer or Item</th>
            <th width="144" scope="col">Fee</th>
          </tr>
          <tr>
            <td><input name="Receptacles" type="text" id="Receptacles" size="5" on /></td>
            <td>Receptacles</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Switches" type="text" id="Receptacles2" size="5" /></td>
            <td>Switches</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Lights" type="text" id="Receptacles3" size="5" /></td>
            <td>Lights</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Ranges_Ovens" type="text" id="Receptacles4" size="5" /></td>
            <td>Ranges / Ovens</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Dryers" type="text" id="Receptacles5" size="5" /></td>
            <td>Dryers</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Water_Heater" type="text" id="Receptacles6" size="5" /></td>
            <td>Water Heaters</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Air_Conditioner" type="text" id="Receptacles7" size="5" /></td>
            <td>Air Conditioners</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Heat" type="text" id="Heat" size="5" /></td>
            <td>Heat</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Sub_panel" type="text" id="Sub_panel" size="5" /></td>
            <td>Sub Panels</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="Temp_service" type="text" id="Temp_service" size="5" /></td>
            <td>Temporary Service</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="No_Meters_Residential" type="text" id="No_Meters_Residential" size="5" /></td>
            <td>No. of Meters Residential</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="No_Meters_Commercial" type="text" id="No_Meters_Commercial" size="5" /></td>
            <td>No. of Meteres Commercial</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="permit_fee" type="text" id="permit_fee" size="5" /></td>
            <td>Permit Fee</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td align="right">Total Permit Fee</td>
            <td><input type="text" name="total_fee" id="total_fee2" /></td>
          </tr>
        </table>
      <br /></div>
            <br />   


        <hr />
        <div id="valueOfPermit">
          <table width="825">
            <tr>
              <td width="97"><input type="button" value="Calculate Cost" onclick="Cal();" /></td>
              <td width="113">Value:
                <input name="valuation" type="text" class="customerInfo" id="valuation" value=" " size="11" /></td>
              <td width="184">Plan Review Fee:
                <input name="planRevFee" type="text" class="customerInfo" id="planRevFee" value="" size="11" /></td>
              <td width="150">Permit Fee:
                <input name="permitFee" type="text" class="customerInfo" id="permitFee" value="" size="11" /></td>
              <td width="282">&nbsp;</td>
            </tr>
          </table>
        </div>
        <div id="permitdetailMain">
          <table width="825">
          <tr>
            <td width="310">Contact Name:</td>
            <td width="113">Phone:
              <label for="contactNumber2"></label></td>
            <td width="386">Fax: </td>
          </tr>
          <tr>
            <td><input style="background-color:#FF7D7D"  name="contactName" type="text" id="contactName" size="50" /></td>
            <td><input style="background-color:#FF7D7D" name="contactNumber" type="text" id="contactNumber" size="10" /></td>
            <td><input style="background-color:#FF7D7D" name="contactFax" type="text" id="contactFax" size="10" /></td>
          </tr>
        </table>
        <table width="825">
          <tr>
            <td width="124">Applicant Signature:</td>
            <td width="689">&nbsp;</td>
          </tr>
        </table>
      </div>
      <input type="hidden" name="permit_id" value="" />
      <input type="hidden" name="MM_insert" value="permit" />
      <input type="submit" value="Insert Permit" />
      <input type="submit" name="Print" id="Print" value="Print Permit" />
    </form>
  </div>
</div>
<p>&nbsp;</p>
</body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.