Jump to content

text box calculation help


aliasneo86

Recommended Posts

please help me with this calculation

=============================================

<?php
$test123 = $_POST['testsel'];
$test456 = $_POST['test'];
//$testall = $test456 * 10;

mysql_select_db($database_web, $web);
$query_Recordset1 = "SELECT strProductID FROM tblicinventory ORDER BY strProductID ASC";
$Recordset1 = mysql_query($query_Recordset1, $web) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);



mysql_select_db($database_web, $web);
$query_test = "SELECT curCost FROM tblicinventory where strProductID = '$test123'";
$test = mysql_query($query_test, $web) or die(mysql_error());
$row_test = mysql_fetch_assoc($test);
$totalRows_test = mysql_num_rows($test);

$testall = $row_test['curCost'];
$testall1 = $testall * 10;

?>
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="test1" method="post" action="">
  <p>
    <select name="testsel" onchange="document.forms['test1'].submit()"  >
      <option value="0" selected value= "<?php echo $test123; ?>"  ><?php echo $test123; ?></option>
      <?php
do {  
?>
      <option value="<?php echo $row_Recordset1['strProductID']?>"><?php echo $row_Recordset1['strProductID']?></option>
      <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
    </select>
</p>
  <p><input name="test" type="text" value="<?php echo $row_test['curCost']; ?>" /> 
  </p>
  <p><input name="text2" type="text"  /></p>
  <p>
    <input type="text" name="textfield" value="<?php echo $testall1; ?>" />
  </p>
</form>
<?php echo $test123; ?>

<!--
<form id="form2" name="form2" method="post" action="">
<input name="text2" type="text" />
</form>-->
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($test);
?>

======================================================

testsel = the menubox

test = the price text box

text2 =  quantity text box

textfield = full price textbox

 

The test textbox is a dynamic text box that the value is changed automatically if the menu value is changed. I want to put a number in the quantity textbox and onblur i want to calculate the fullprice text box that will be price * quantity

but if the menu is changed i want the calculation to be done withthe new price in the price text box

 

I will be really thank ful if any one can help me with this.

 

thank you,

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.