Tinkerbell
|
| Posted: 04/17/2005, 6:12 PM |
|
How can I add a line to the HTML Javascript using the Order Entry-CCSExamplePack, that will change the Unit Price and SumPrice to a 0 (zero) value when a user clicks a checkbox next to the SumPrice box that I add. I was able to incorporate this design into an application I'm building. There's at least 4 different function used in the Order Entry javascript, but I'm not sure where in the script I'm able to add the variable.
When a user selects a product from the drop down listbox, it automatically inserts the value of that product into the Unit Price textbox and when the user tabs to the Quantity field, it automatically takes the unit price times the quantity and inserts the SumPrice. In my form, once the product type and unit price is displayed, I want the user to have the ability to waive the unit price which allows them to place a check in a checkbox I supply. When the user enters a value in the checkbox, I want this value to have the ability to change the Unit Price, Quantity and SumPrice to a zero value. Keep in mind that if the user selects more than one value, it only changes the value that the checkbox corresponse to. (I hope this make since.) I have included the Javascript found in the Order Entry example of the CCSExamplePack. (See Below.)
Javascript:
<html>
<head>
<meta name="GENERATOR" content="CodeCharge Studio 2.3.2.24">
<title>ARS</title>
<script language="JavaScript">
function StrToFloat(str)
{
if (str.indexOf(",") != -1) {
str = str.replace(",",".");
}
var result = parseFloat(str);
if (isNaN(result)) {
result = 0.0;
}
return result;
}
The example below shows how I was able to add an example called waivedCheckbox, to change the Total_price field, to see if this value would change if a checkbox was selected. What this did was to enter the variable "99" to the Total_price textbox when a checkbox was selected. I got this part to work, but this is not what I'm looking for. I only need the UnitPrice and SumPrice to zero out on the product selected, and then, subtract the value from the Total_price. I have an onClick event within the <input type=checkbox> field that invokes this example. Without the onClick event, is there another way to invoke this in the function ShowTotal() script. (See below.)
function waivedCheckBox()
{
document.store_orders_items.Total_price.value = 99;
}
function Show_Total()
{
function Show_Total()
{
var TotalSum=0;
var Summ;
for(var i = 0; i < store_orders_itemsElements.length; i++){
Summ = StrToFloat(store_orders_itemsElements[store_orders_itemspriceID].value) *
StrToFloat(store_orders_itemsElements[store_orders_itemsquantityID].value);
TotalSum = TotalSum + Summ;
if (Summ == 0) {
store_orders_itemsElements[store_orders_itemsSumPriceID].value = "";
} else {
store_orders_itemsElements[store_orders_itemsSumPriceID].value = Math.round(Summ*100)/100;
}
}
document.store_orders_items.Total_price.value = Math.round(TotalSum*100)/100;
}
function disable_editablegrid()
{
if (document.forms["store_orders_items"]) {
for(var i = 0; i < store_orders_itemsElements.length; i++){
store_orders_itemsElements[store_orders_itemsproduct_idID].disabled = true;
store_orders_itemsElements[store_orders_itemsquantityID].disabled = true;
store_orders_itemsElements[store_orders_itemspriceID].disabled = true;
}
document.store_orders_items.Button_Submit.disabled = true;
}
}
//Begin CCS script
//Include JSFunctions @1-7033547D
</script>
<script language="JavaScript" type="text/javascript" src="functions.js"></script>
<script language="JavaScript" type="text/javascript">
//End Include JSFunctions
//page_store_orders_items_product_id_OnChange @9-4CABBD66
function page_store_orders_items_product_id_OnChange()
{
var result;
//End page_store_orders_items_product_id_OnChange
//Custom Code @10-2A29BDB7
var Element_Number = this.name.substring(11)-1;
var Element_ID = store_orders_itemsElements[Element_Number][store_orders_itemsproduct_idID].value;
if (parseInt(Element_ID) > 0) {
store_orders_itemsElements[Element_Number][store_orders_itemspriceID].value = product_price[parseInt(Element_ID)];
} else {
store_orders_itemsElements[Element_Number][store_orders_itemspriceID].value = 0;
}
Show_Total();
disable_record();
//End Custom Code
|
|
|
 |
|