Hej jeg håber der er nogle der kan hjælpe med en kode til udregning.
Den skal gange højde x længde x brede = total og jeg vil gerne have onKeyUp fungtionen så totalen kommer automatisk når man har skrevet de 3 andre felter.
Her er felterne:
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_hoj_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_hoj', $pInfo->products_hoj); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_lang_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_lang', $pInfo->products_lang); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_bred_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_bred', $pInfo->products_bred); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_VOLUME_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_volume', $pInfo->products_volume); ?></td>
</tr>
</table></td>
her er hele koden over hvis det er nødvendigt:
while ($description = tep_db_fetch_array($description_query)) {
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
}
tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
$products_id = $dup_products_id;
}
if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
}
}
tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id));
break;
case 'new_product_preview':
// copy image only if modified
$products_image = new upload('products_image');
$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
if ($products_image->parse() && $products_image->save()) {
$products_image_name = $products_image->filename;
} else {
$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
}
break;
}
}
// check if the catalog image directory exists
if (is_dir(DIR_FS_CATALOG_IMAGES)) {
if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
} else {
$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top">
<?php
if ($action == 'new_product') {
$parameters = array('products_name' => '',
'products_description' => '',
'products_url' => '',
'products_id' => '',
'products_quantity' => '',
'products_model' => '',
'products_image' => '',
'products_price' => '',
'products_weight' => '',
'products_date_added' => '',
'products_last_modified' => '',
'products_date_available' => '',
'products_status' => '',
'products_tax_class_id' => '',
'manufacturers_id' => '');
$pInfo = new objectInfo($parameters);
if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_volume, p.products_hoj, p.products_lang, p.products_bred, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product = tep_db_fetch_array($product_query);
$pInfo->objectInfo($product);
} elseif (tep_not_null($HTTP_POST_VARS)) {
$pInfo->objectInfo($HTTP_POST_VARS);
$products_name = $HTTP_POST_VARS['products_name'];
$products_description = $HTTP_POST_VARS['products_description'];
$products_url = $HTTP_POST_VARS['products_url'];
}
$manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
'text' => $manufacturers['manufacturers_name']);
}
$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
$tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
while ($tax_class = tep_db_fetch_array($tax_class_query)) {
$tax_class_array[] = array('id' => $tax_class['tax_class_id'],
'text' => $tax_class['tax_class_title']);
}
$languages = tep_get_languages();
if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
switch ($pInfo->products_status) {
case '0': $in_status = false; $out_status = true; break;
case '1':
default: $in_status = true; $out_status = false;
}
?>
<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script language="javascript"><!--
var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
//--></script>
<script language="javascript"><!--
var tax_rates = new Array();
<?php
for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {
if ($tax_class_array[$i]['id'] > 0) {
echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "n";
}
}
?>
function doRound(x, places) {
return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
}
function getTaxRate() {
var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;
var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;
if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
return tax_rates[parameterVal];
} else {
return 0;
}
}
function updateGross() {
var taxRate = getTaxRate();
var grossValue = document.forms["new_product"].products_price.value;
if (taxRate > 0) {
grossValue = grossValue * ((taxRate / 100) + 1);
}
document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
}
function updateNet() {
var taxRate = getTaxRate();
var netValue = document.forms["new_product"].products_price_gross.value;
if (taxRate > 0) {
netValue = netValue / ((taxRate / 100) + 1);
}
document.forms["new_product"].products_price.value = doRound(netValue, 4);
}
//--></script>
<?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"'); ?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('products_status', '1', $in_status) . ' ' . TEXT_PRODUCT_AVAILABLE . ' ' . tep_draw_radio_field('products_status', '0', $out_status) . ' ' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><small>(YYYY-MM-DD)</small></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' '; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<?php
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
<tr>
<td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td>
<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_name[' . $languages[$i]['id'] . ']', (isset($products_name[$languages[$i]['id']]) ? $products_name[$languages[$i]['id']] : tep_get_products_name($pInfo->products_id, $languages[$i]['id']))); ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr bgcolor="#ebebff">
<td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id, 'onchange="updateGross()"'); ?></td>
</tr>
<tr bgcolor="#ebebff">
<td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price', $pInfo->products_price, 'nKeyUp="updateGross()"'); ?></td>
</tr>
<tr bgcolor="#ebebff">
<td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price_gross', $pInfo->products_price, 'nKeyUp="updateNet()"'); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<script language="javascript"><!--
updateGross();
//--></script>
<?php
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
<tr>
<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>
<td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($products_description[$languages[$i]['id']]) ? $products_description[$languages[$i]['id']] : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td>
</tr>
</table></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('products_image') . '' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<?php
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
<tr>
<td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_URL . '<small>' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . '</small>'; ?></td>
<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_url[' . $languages[$i]['id'] . ']', (isset($products_url[$languages[$i]['id']]) ? $products_url[$languages[$i]['id']] : tep_get_products_url($pInfo->products_id, $languages[$i]['id']))); ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_hoj_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_hoj', $pInfo->products_hoj); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_lang_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_lang', $pInfo->products_lang); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_bred_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_bred', $pInfo->products_bred); ?></td>
</tr>
<tr>
<td class="main"><?php echo TEXT_PRODUCTS_VOLUME_TEXT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_volume', $pInfo->products_volume); ?></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main" align="right"><?php echo tep_draw_hidden_field('products_date_added', (tep_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
</tr>
</table></form>
<?php
[Redigeret d. 27/05-04 16:35:49 af avu][Redigeret d. 27/05-04 16:37:33 af avu]