Hello,

First let me start of by saying that I am new to javascript and ajax, but I thing I need them to accomplish what I am trying to do and here it is.

I have there search forms, 1 search owner, 2 search contractor, 3 search properity. Then I have a form on the same page that each of these searches are to populate from the form and insert the data into MySQL. I have the searches doing the job except when I move from one search to the other the first search is cleared from the form. The search shows the details of and the primary id from the searches is to be passed on in the form that it is populating to the database. I have been researching and it seems that what I am looking for is to have a autolookup for the searches with out a page refreash, but that is out of my capabilities. I have not found any samples of what I am trying to do. I know that there is someone that know how to do this and might be able to point me in the right direction to understand it.

this is the page:

http://www.1stsourcesolution.com/Inspectit/addPermit2.php

The code is as follow for the page:

<?php require_once('../Connections/MySql_connection.php'); ?>

<?php

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;

}

}

/* record sets */

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rsZoning = "SELECT zoning_district.zoning_district, zoning_district.Zone_description, zoning_district.`idzoning district` FROM zoning_district";

$rsZoning = mysql_query($query_rsZoning, $MySql_connection) or die(mysql_error());

$row_rsZoning = mysql_fetch_assoc($rsZoning);

$totalRows_rsZoning = mysql_num_rows($rsZoning);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rsFlood = "SELECT flood_zone.flood_zone, flood_zone.`idflood zone` FROM flood_zone";

$rsFlood = mysql_query($query_rsFlood, $MySql_connection) or die(mysql_error());

$row_rsFlood = mysql_fetch_assoc($rsFlood);

$totalRows_rsFlood = mysql_num_rows($rsFlood);

 

$colname_rsPermit = "-1";

if (isset($_GET['permit_id'])) {

  $colname_rsPermit = $_GET['permit_id'];

}

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rsPermit = sprintf("SELECT * FROM permit WHERE permit_id = %s", GetSQLValueString($colname_rsPermit, "int"));

$rsPermit = mysql_query($query_rsPermit, $MySql_connection) or die(mysql_error());

$row_rsPermit = mysql_fetch_assoc($rsPermit);

$totalRows_rsPermit = mysql_num_rows($rsPermit);

 

$colname_rscontractor = "-1";

if (isset($_POST['conSearch'])) {

  $colname_rscontractor = $_POST['conSearch'];

}

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rscontractor = sprintf("SELECT * FROM contractor WHERE Company_Name LIKE %s", GetSQLValueString($colname_rscontractor . "%", "text"));

$rscontractor = mysql_query($query_rscontractor, $MySql_connection) or die(mysql_error());

$row_rscontractor = mysql_fetch_assoc($rscontractor);

$totalRows_rscontractor = mysql_num_rows($rscontractor);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rsWorkClass = "SELECT * FROM work_classification";

$rsWorkClass = mysql_query($query_rsWorkClass, $MySql_connection) or die(mysql_error());

$row_rsWorkClass = mysql_fetch_assoc($rsWorkClass);

$totalRows_rsWorkClass = mysql_num_rows($rsWorkClass);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rsTypeConstruction = "SELECT * FROM type_of_construction";

$rsTypeConstruction = mysql_query($query_rsTypeConstruction, $MySql_connection) or die(mysql_error());

$row_rsTypeConstruction = mysql_fetch_assoc($rsTypeConstruction);

$totalRows_rsTypeConstruction = mysql_num_rows($rsTypeConstruction);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rsBuildingUse = "SELECT * FROM occupance";

$rsBuildingUse = mysql_query($query_rsBuildingUse, $MySql_connection) or die(mysql_error());

$row_rsBuildingUse = mysql_fetch_assoc($rsBuildingUse);

$totalRows_rsBuildingUse = mysql_num_rows($rsBuildingUse);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rstms = "SELECT tms_id, TMS, ONAME, ADDR, CITY, `STATE`, ZIP, SUBD, LEGAL FROM tax_map";

$rstms = mysql_query($query_rstms, $MySql_connection) or die(mysql_error());

$row_rstms = mysql_fetch_assoc($rstms);

$totalRows_rstms = mysql_num_rows($rstms);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_searchCustomer = "SELECT * FROM customer_owner";

$searchCustomer = mysql_query($query_searchCustomer, $MySql_connection) or die(mysql_error());

$row_searchCustomer = mysql_fetch_assoc($searchCustomer);

$totalRows_searchCustomer = mysql_num_rows($searchCustomer);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_typePermit = "SELECT * FROM permit_classification";

$typePermit = mysql_query($query_typePermit, $MySql_connection) or die(mysql_error());

$row_typePermit = mysql_fetch_assoc($typePermit);

$totalRows_typePermit = mysql_num_rows($typePermit);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_architect = "SELECT * FROM arcitectengineer";

$architect = mysql_query($query_architect, $MySql_connection) or die(mysql_error());

$row_architect = mysql_fetch_assoc($architect);

$totalRows_architect = mysql_num_rows($architect);

 

mysql_select_db($database_MySql_connection, $MySql_connection);

$query_rsOccupancy = "SELECT occupancy_id, type_of_occupancy, occupancy_description FROM occupance";

$rsOccupancy = mysql_query($query_rsOccupancy, $MySql_connection) or die(mysql_error());

$row_rsOccupancy = mysql_fetch_assoc($rsOccupancy);

$totalRows_rsOccupancy = mysql_num_rows($rsOccupancy);

?>

 

 

 

 

 

<!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>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

 

<body>

<p>PERMIT:

</p>

        <form id="searchOwnProp" name="searchOwnProp" method="post" action="<?php echo $_SERVER ['PHP_SELF'];?>">

Search for Owner of Properity:

          <label for=""></label>

          <input name="properitySearch" type="text" id="properitySearch" />

          <input type="submit" name="button" id="button" value="Search" />

        </form>

        <form id="searchContractor" name="searchContractor" method="post" action="">

Search Contractors:

          <label for="conSearch"></label>

          <input type="text" name="conSearch" id="conSearch" />

          <input type="submit" name="Search" id="Search" value="Submit" />

        </form>

        <form id="searchLeasee" name="searchLeasee" method="post" action="<?php echo $_SERVER ['PHP_SELF'];?>">

          <p>Search for Lessee of Properity:

            <label for="label"></label>

            <input name="LesseeSearch" type="text" id="LesseeSearch" />

            <input type="submit" name="button3" id="button3" value="Search"/>

          </p>

          <p> </p>

        </form>

        <form id="insertPermit"name"insertPerimt" method="post"action

        "">

          <table width="1171" border="0" align="left">

            <tr>

              <td colspan="4"><p>Job Site<br />

                /Physical Address:

                <label for="MADD"></label>

                <label for="jobSite"></label>

                <?php echo $row_rstms['LEGAL']; ?>            </p></td>

              <td width="170" align="right">Bldg Use

                <select name="occupancy" id="occupancy2" title="<?php echo $row_rsOwnerProp['USECD']; ?>">

                  <?php

do { 

?>

                  <option value="<?php echo $row_rsBuildingUse['occupancy_id']?>"><?php echo $row_rsBuildingUse['type_of_occupancy']?></option>

                  <?php

} while ($row_rsBuildingUse = mysql_fetch_assoc($rsBuildingUse));

  $rows = mysql_num_rows($rsBuildingUse);

  if($rows > 0) {

      mysql_data_seek($rsBuildingUse, 0);

      $row_rsBuildingUse = mysql_fetch_assoc($rsBuildingUse);

  }

?>

                </select></td>

              <td colspan="2"><label for="occupancy2">Zone District

                <select name="zoning" id="zoning">

                  <?php

do { 

?>

                  <option value="<?php echo $row_rsZoning['idzoning district']?>"><?php echo $row_rsZoning['zoning_district']?></option>

                  <?php

} while ($row_rsZoning = mysql_fetch_assoc($rsZoning));

  $rows = mysql_num_rows($rsZoning);

  if($rows > 0) {

      mysql_data_seek($rsZoning, 0);

      $row_rsZoning = mysql_fetch_assoc($rsZoning);

  }

?>

                </select>

                </label>              <label for="zoning"></label></td>

            </tr>

            <tr>

              <td colspan="2"> TMS#              :

                <label for="taxmapID"></label>

                <input name="taxmapID" type="text" id="taxmapID" value="<?php echo $row_rstms['TMS']; ?>" /></td>

              <td width="167">Block

                <label for="block"></label>

                <input type="text" name="block" id="block" /></td>

              <td width="180">Subdividion/Complex:<?php echo $row_rstms['SUBD']; ?></td>

              <td>Lot No.

                <input name="lotno" type="text" id="lotno" size="6" /></td>

              <td colspan="2"><label for="subdivision"></label>

                <label for="textfield">Flood Zone

                  <select name="flood_zone" id="flood_zone2">

                    <?php

do { 

?>

                    <option value="<?php echo $row_rsFlood['idflood zone']?>"><?php echo $row_rsFlood['flood_zone']?></option>

                    <?php

} while ($row_rsFlood = mysql_fetch_assoc($rsFlood));

  $rows = mysql_num_rows($rsFlood);

  if($rows > 0) {

      mysql_data_seek($rsFlood, 0);

      $row_rsFlood = mysql_fetch_assoc($rsFlood);

  }

?>

                  </select>

                </label></td>

            </tr>

            <tr>

              <td colspan="2"> </td>

              <td colspan="2"> </td>

              <td> </td>

              <td align="center"> </td>

              <td align="center"> </td>

            </tr>

            <tr>

              <td colspan="2">Owner of Property ID:<?php echo $row_rstms['tms_id']; ?>:

                <label for="ownProp"></label>

                <label for="ONAME"></label>

                <?php echo $row_rstms['ONAME']; ?></td>

              <td colspan="2">Mailing Address:

                <label for="textfield2"></label>

                <label for="MADD2"><?php echo $row_rstms['ADDR']; ?></label></td>

              <td>City:

                <label for="textfield3"></label>

                <label for="city"><?php echo $row_rstms['CITY']; ?></label></td>

              <td width="115" align="center">State:<?php echo $row_rstms['STATE']; ?>

                <label for="textfield4"></label>

                <label for="starte"></label></td>

              <td width="163" align="center">Zip:

                <?php echo $row_rstms['ZIP']; ?>

                <label for="textfield5"></label>

                <label for="zip"></label></td>

            </tr>

            <tr>

              <td width="164">Phone

                <input name="textfield17" type="text" id="textfield17" size="10" /></td>

              <td width="185">Fax

                <input name="textfield18" type="text" id="textfield18" size="10" /></td>

              <td colspan="2">Email

                <label for="textfield15"></label>

                <input type="text" name="textfield25" id="textfield15" /></td>

              <td> </td>

              <td align="center" valign="middle"> </td>

              <td align="center"> </td>

            </tr>

            <tr>

              <td colspan="2"> </td>

              <td colspan="2"> </td>

              <td> </td>

              <td align="center" valign="middle"> </td>

              <td align="center"> </td>

            </tr>

            <tr>

              <td colspan="2">Leassee of Building ID:

                <label for="lesee">

                  <input name="Leasee" type="text" id="Leasee" value="<?php echo $row_searchCustomer['customer_id']; ?>" size="9" />

                <?php echo $row_searchCustomer['first_name']; ?><?php echo $row_searchCustomer['last_name']; ?></label></td>

              <td colspan="2">Mailing Address: <?php echo $row_searchCustomer['address']; ?></td>

              <td>City:

                <label for="textfield7"><?php echo $row_searchCustomer['city']; ?></label></td>

              <td align="center" valign="middle">State:

                <label for="textfield8"><?php echo $row_searchCustomer['state']; ?></label></td>

              <td align="center">Zip:

                <label for="textfield9"></label>

                <?php echo $row_searchCustomer['zip']; ?></td>

            </tr>

            <tr>

              <td>Phone:

                <label for="textfield16"><?php echo $row_searchCustomer['phone_number']; ?> Cell: <?php echo $row_searchCustomer['cell_number']; ?></label></td>

              <td align="center" valign="bottom">Fax:              </td>

              <td colspan="2">Email:              <?php echo $row_searchCustomer['email']; ?></td>

              <td> </td>

              <td align="center"> </td>

              <td align="center"> </td>

            </tr>

            <tr>

              <td colspan="2"> </td>

              <td colspan="2"> </td>

              <td> </td>

              <td align="center"> </td>

              <td align="center"> </td>

            </tr>

            <tr>

              <td colspan="2">Contractor ID:

                <label for="lesee">

                  <input name="contractor" type="text" id="contractor" value="<?php echo $row_rscontractor['contractor_id']; ?>" size="9" />

                <?php echo $row_rscontractor['Company_Name']; ?></label></td>

              <td colspan="2">Mailing Address: <?php echo $row_rscontractor['address']; ?></td>

              <td>City: <?php echo $row_rscontractor['city']; ?></td>

              <td align="center">State:             

                <label for="textfield12"><?php echo $row_rscontractor['state']; ?></label></td>

              <td align="center">Zip: <?php echo $row_rscontractor['zip']; ?></td>

            </tr>

            <tr>

              <td>Phone: <?php echo $row_rscontractor['phone_no']; ?> Cell:<?php echo $row_rscontractor['cell_phone']; ?></td>

              <td>Fax

                <input name="textfield20" type="text" id="textfield20" size="10" /></td>

              <td colspan="2">Email:              <?php echo $row_rscontractor['email']; ?></td>

              <td valign="bottom">State Lic: <?php echo $row_rscontractor['state_lic_no']; ?></td>

              <td align="center"> </td>

              <td align="center">City Lic:<?php echo $row_rscontractor['city_lic_no']; ?></td>

            </tr>

            <tr>

              <td colspan="2">Contact

                <label for="contact"></label>

                <input name="contact" type="text" id="contact" value="<?php echo $row_rscontractor['last_name']; ?>" size="50" /></td>

              <td colspan="2"> </td>

              <td valign="bottom">Exp:<?php echo $row_rscontractor['state_exp_date']; ?></td>

              <td align="center"> </td>

              <td align="center">Exp:<?php echo $row_rscontractor['city_exp_date']; ?></td>

            </tr>

            <tr>

              <td colspan="2"> </td>

              <td colspan="2"> </td>

              <td> </td>

              <td align="center"> </td>

              <td align="center"> </td>

            </tr>

            <tr>

              <td colspan="2">Architect/Engineer ID:

                <label for="archEngineer"></label>

                <input name="archEngineer" type="text" id="archEngineer" size="9" /></td>

              <td colspan="2">Mailling Address:

                <label for="arch_addr"></label></td>

              <td>City:

                <label for="textfield11"></label></td>

              <td align="center">State:

                <label for="textfield13"></label></td>

              <td align="center">Zip:

                <label for="arch_zip"></label></td>

            </tr>

            <tr>

              <td>Phone:              </td>

              <td>Fax

                <input name="textfield21" type="text" id="textfield21" size="10" /></td>

              <td colspan="2">Email:              </td>

              <td valign="bottom">State Lic:

                <label for="st_lic_no2"></label></td>

              <td> </td>

              <td align="center">City Lic:

                <label for="city_lic2"></label></td>

            </tr>

            <tr>

              <td colspan="2">Contact

                <input name="contact" type="text" id="contact" size="50" /></td>

              <td colspan="2">Email

                <label for="contact_email"></label>

                <input name="contact_email" type="text" id="contact_email" size="50" /></td>

              <td valign="bottom"> </td>

              <td> </td>

              <td align="center"> </td>

            </tr>

            <tr>

              <td colspan="2"> </td>

              <td colspan="2"> </td>

              <td> </td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

              <td colspan="2"> </td>

              <td colspan="2"> </td>

              <td> </td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

              <td colspan="2">Work Classification

                <label for="workClass">

                  <select name="workClass" id="workClass">

                    <?php

do { 

?>

                    <option value="<?php echo $row_rsWorkClass['idwork classification']?>"><?php echo $row_rsWorkClass['work_classification']?></option>

                    <?php

} while ($row_rsWorkClass = mysql_fetch_assoc($rsWorkClass));

  $rows = mysql_num_rows($rsWorkClass);

  if($rows > 0) {

      mysql_data_seek($rsWorkClass, 0);

      $row_rsWorkClass = mysql_fetch_assoc($rsWorkClass);

  }

?>

                  </select>

                </label></td>

              <td colspan="2"> </td>

              <td> </td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

              <td colspan="7" valign="top">Description of Work:

                <textarea name="work" id="work" cols="100" rows="5"></textarea>

                <label for="work"></label>

                <label for="work"></label></td>

            </tr>

            <tr>

              <td>Total Valuation

                <label for="value"></label>

                <input name="value" type="text" id="value" size="19" /></td>

              <td>Plan Check Fee

                <label for="planRevFee2"></label>

                <input name="planRevFee" type="text" id="planRevFee2" size="19" /></td>

              <td>Permit Fee

                <label for="permitFee2"></label>

                <input name="permitFee" type="text" id="permitFee2" size="19" /></td>

              <td>Total Permit Fee

                <input type="text" name="total_fee" id="total_fee" /></td>

              <td colspan="2"> </td>

              <td align="right"> </td>

            </tr>

            <tr>

              <td colspan="2">Date Received

                <label for="dateRec"></label>

                <input name="dateRec" type="text" id="dateRec" /></td>

              <td colspan="2">Date Issued

                <label for="dateIssu"></label>

                <input type="text" name="dateIssu" id="dateIssu" /></td>

              <td> </td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

              <td colspan="2">Type Constructin

                <select name="type_construction" id="type_construction">

                  <?php

do { 

?>

                  <option value="<?php echo $row_rsTypeConstruction['construction_id']?>"><?php echo $row_rsTypeConstruction['type_of_construction']?></option>

                  <?php

} while ($row_rsTypeConstruction = mysql_fetch_assoc($rsTypeConstruction));

  $rows = mysql_num_rows($rsTypeConstruction);

  if($rows > 0) {

      mysql_data_seek($rsTypeConstruction, 0);

      $row_rsTypeConstruction = mysql_fetch_assoc($rsTypeConstruction);

  }

?>

                </select></td>

              <td colspan="2"><label for="type_construction"></label></td>

              <td>Sprinkled</td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

              <td colspan="2">Contact Name

                <label for="textfield23"></label>

                <input name="textfield23" type="text" id="textfield23" size="50" /></td>

              <td colspan="2" valign="bottom">Phone

                <label for="textfield22"></label>

                <input name="textfield22" type="text" id="textfield22" size="10" /></td>

              <td valign="bottom">Fax

                <label for="textfield24"></label>

                <input name="textfield24" type="text" id="textfield24" size="10" /></td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

              <td height="21" colspan="2"> </td>

              <td colspan="2"> </td>

              <td> </td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

              <td colspan="2"><input type="submit" name="button2" id="button2" value="Inset Record" /></td>

              <td colspan="2"> </td>

              <td> </td>

              <td> </td>

              <td> </td>

            </tr>

            <tr>

             

            </tr>

          </table>

</form>

        <p><br />

  </p>

 

 

</body>

</html>

<?php mysql_free_result($rspermitslist);

 

mysql_free_result($rsZoning);

 

mysql_free_result($rstms);

 

mysql_free_result($searchCustomer);

 

mysql_free_result($typePermit);

 

mysql_free_result($architect);

 

mysql_free_result($rsOccupancy);

 

mysql_free_result($rsZoning);

 

mysql_free_result($rsZoning);

 

mysql_free_result($rsZoning);

 

mysql_free_result($rsFlood);

 

mysql_free_result($rsInspection);

 

mysql_free_result($rsPermit);

 

mysql_free_result($rscontractor);

 

mysql_free_result($rsWorkClass);

 

mysql_free_result($rsTypeConstruction);

 

mysql_free_result($rsBuildingUse);

 

mysql_free_result($rspermitslist);?>

Thanks for any help

I have the searches doing the job except when I move from one search to the other the first search is cleared from the form.

i assume you are looking to search where info(some detail) = search 1 and search 2
that being the case you need to pass the value of both search fields to your function
by having them in the same form (this can give you bad results if someone started typing in another field)
keeping them in separate forms with hidden values for the other fields containing the results of previous searches

<form>
<input name="search"/>
<input type="hidden" name="other search" value="previous value"/>
</form>

old values stay in place to you replace them or clear them with some sort of clear function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.