aliasneo86 Posted October 13, 2008 Share Posted October 13, 2008 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, Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted October 13, 2008 Share Posted October 13, 2008 onBlur is javascript. Unless you intend to use Ajax you would be probably better looking at javascript to do the calculations in real time. Quote Link to comment Share on other sites More sharing options...
aliasneo86 Posted October 13, 2008 Author Share Posted October 13, 2008 ok can you plz show me an example coding ?? I dont know any thing about java script thanks for your reply, Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted October 20, 2008 Share Posted October 20, 2008 write this code in the output field in onblug event onblur="document.form1.textfield.value=((document.form1.test.value)*(document.form1.text2.value))" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.