Page 1 of 1

HELP adding a row in my inquiry form

Posted: Wed Nov 30, 2005 8:38 am
by pido
Hi its me again 8) I have a problem using PHP to make my inquiry form works... Basically I have two pages addSalesInvoice.php and addDetail.php, the idea was:

1. User input all data to form parent(addSalesInvoice.php) & child(addDetail.php), in child when user put a PART ID like 705-52-30080 it will submit the query, refresh the page and display the PART ID's info.
2. When user click Add or Delete button it will add or delete last row in table in iframe(addDetail.php) <-- HOW DO I DO THIS????
3. Click Save button to save all data(Parent&Child) in database

I have this page addSalesInquiry.php

Code: Select all

?><table class="main" cellpading="0" cellspacing="1" width="100%">
 <tr>
  <td colspan="5" align="center">
   <input type="button" class="button" name="action" value="Find Code" onClick="">
   <input type="button" class="button" name="action" value="Add" onClick="addRowToTable();"> // Add row in table addDetail.php
   <input type="button" class="button" name="action" value="Delete" onClick="removeRowFromTable()"> // Delete row in table addDetail.php
   <input type="button" class="button" name="action" value="Save" onClick=""> // Save all data in parent and child page
   <input type="button" class="button" name="action" value="Close" onClick="closeWindow(this)">
  </td>
 </tr>
 <tr>
  <td width="100%" colspan="5">
   <iframe class="detail" src="addDetail.php" frameborder="0" name="detail" scrolling="auto">Your Browser Don't Support Iframe please use IE5.0 above</iframe>
  </td>
 </tr>
</table>
addDetail.php

Code: Select all

?><table width="100%" border="0" cellspacing="0" cellpadding="0" id="tblDetail">
 <tr>
  <td class="header" width="25">No.</td>
  <td class="header" width="167">Part Number</td>
  <td class="header" width="41">Qty</td>
  <td class="header" width="101">Harga Offer</td>
  <td class="header" width="*">Description</td>
  <td class="header" width="100">Harga (Rp)</td>
  <td class="header" width="100">Harga (US$)</td>
  <td class="header" width="100">Action</td>
 </tr>
 <tr>
 <form action="addDetail.php" method="POST" name="detailAction">
  <td class="content" align="center">1</td>
  <?
  if (isset($HTTP_POST_VARS["partNumber"])){
  $part = $_POST["partNumber"];
  ?>
  <input type="hidden" name="part[<? echo "$part"; ?>]" value="<? echo "$part"; ?>">
  <td class="content"><? echo "$part"; ?></td>
  <?
  }
  else{
  ?>
  <td class="content" align="center"><input type="text" class="detail" name="partNumber" id="txtRow1" size="24" onChange="this.form.submit();"></td>
  <?
  }
  ?>
  <td class="content" align="center"><input type="text" class="detail" name="quantity" id="txtRow1" size="3"></td>
  <td class="content" align="center"><input type="text" class="detail" name="harga" id="txtRow1" size="13"></td>
  </form>
  <?
  if (isset($HTTP_POST_VARS["partNumber"])){
  $id = $_POST["partNumber"];
  $query = "SELECT NM_PRO,FORMULA_ID,HRG_JUAL_RP,UT_UPUS FROM IM_PRODUCT WHERE FORMULA_ID = '".$id."'";
  $result = mssql_query($query) or die();
  $row = mssql_fetch_array($result);
  mssql_free_result($result);
  ?>
  <td class="content" id="partName"><? if ($row[0] == ""){echo "&nbsp;";}else{echo "$row[0]"; }?></td>
  <td class="integer" id="priceRP" align="right"><font color="#BB8B00"><? echo number_format($row[2],2,'.',','); ?></font></td>
  <td class="integer" id="priceUS" align="right"><font color="#BB8B00">$ <? echo number_format($row[3],2,'.',','); ?></font></td>
  <td class="content" align="center">
   <a href="#"><img src="images/edit.gif" alt="Edit Data" border="0"></a>
   <a href="#"><img src="images/delete.gif" alt="Print Data" border="0"></a>
  </td>
 <?
  }
  else{
  ?>
  <td class="content" id="partName">&nbsp;</td>
  <td class="integer" id="qty" align="center"><font color="#BB8B00">&nbsp;</font></td>
  <td class="integer" id="priceUS" align="right"><font color="#BB8B00">$ 0.00</font></td>
  <td class="content" align="center">
   <a href="#"><img src="images/edit.gif" alt="Edit Data" border="0"></a>
   <a href="#"><img src="images/delete.gif" alt="Print Data" border="0"></a>
  </td>
  <?
  }
  ?>
 </tr>
</table>

Posted: Wed Nov 30, 2005 8:48 am
by shiznatix
do you mean just delete it from the screen, not actually delete the record from the database? if so then read

viewtopic.php?t=41209

because i JUST had this same style problem and it was solved by some very helpful people. if this is the case, then this belongs in a different forum, but im sure you will be forgiven :)