Gravity form Change value of quantity based on previous field selection - gravityforms

Hi I am using Gravity Form, and I am trying to build a form where depending on the service you choose, the quantity of hours will update automatically. For example:
Multiple choice field: 1. Wash a car 2. wash a truck 3. wash a motorbike
Quantity field should pre-populate with either; 1 (if motorbike is selected, or 2 (if car is selected or 3 (if truck is selected)
Any help is much appreciated

A generous developer I know helped me out. Add this code after the form. here is the answer:
<script type="text/javascript">
var helpSelect = document.querySelector('#input_2_22')
var quantityInput = document.querySelector('#input_2_28')
helpSelect.addEventListener('change', function (e) {
quantityInput.value = e.target.value
})
</script>
Remember to change the input id to the id of the input in your form.

Related

How to add a total row for exports from advanced order export for woocommerce plugin?

for a woocommerce shop I am using Single Products with Addons. These are quantity fields that are impacting the price at the end. Such as when you order a Pizza and can add multiple toppings in any quantity.
I need to be able to export a cumulative report that also shows the total amount of each addon. Since my addons are custom meta fields, I am using for the reports the "advanced order export for woocommerce" plugin from AlgolPlus.
With that plugin, I am able to export an excel file that adds for each addon a new column and shows per order the amount of each addon that was ordered. What I would need in addition now, is to display a total row at the end that shows the total amount of ordered addons.
Obviously I know that I can simply add myself a new row with the sum formula but this is for a client and ideally, I want that the report can do this automatically.
Any idea how I can achieve this?
I reached out to the developer, he write the basis of the code and I adjusted it to add last row to each exported XSL report and make that last row in bold font and yellow background color.
Here it is:
add_action( 'woe_xls_print_footer', function ($objXls,$formatter) {
$row = $formatter->last_row;
for($i = 0; $i < PHPExcel_Cell::columnIndexFromString( $formatter->objPHPExcel->getActiveSheet()->getHighestDataColumn() ); $i++ ){
$letter = PHPExcel_Cell::stringFromColumnIndex($i);
$formatter->objPHPExcel->getActiveSheet()->setCellValue( $letter.($row+1), "=SUM(".$letter."2:".$letter.$row.")" );
}
$formatter->objPHPExcel->getActiveSheet()->getStyle("A".($row+1).":".$formatter->objPHPExcel->getActiveSheet()->getHighestDataColumn().($row+1))->getFont()->setBold(true);
$formatter->objPHPExcel->getActiveSheet()->getStyle("A".($row+1).":".$formatter->objPHPExcel->getActiveSheet()->getHighestDataColumn().($row+1))->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFF00');
$formatter->objPHPExcel->getActiveSheet()->setCellValue( "A". ($row+1), "Total" );} ,10, 2);

Tabulator 4.9, is there a way to have 2 different colors of text within a cell?

The requirements from the customer state that a record's Comment and Description fields must be displayed in the same cell but the text of the Comment must be displayed in red while the Description should be black. Using a mutator, I can combine the 2 fields and display them in one cell, but I haven't seen how to make one have red text and the other black text within that cell.
Is there a way?
Thanks,
Matt
I wouldnt bother doing that, just use a Customer Formatter function
formatter:function(cell, formatterParams, onRendered){
return '<span style=color:red>' + cell.getRow().getData().Comment + '</span><P><span style=color:black>' + cell.getRow().getData().Description + '</span></p>';
}

Increase decimal digits displayed on a grid field

Does anyone know how to increase the decimal digits displayed on a grid field?
When you click the ADD STOCK ITEM button on the Sales Orders (SO301000) screen, then click the Sold Since radio button, there is a field called Last Unit Price in the grid.
I would like to increase the decimal digits displayed from 2 to 3 decimals.
I tried customizing the data field using Ctrl+Alt, clicking on the field, and choosing ACTIONS -> Customize Data Fields... which yields this:
[PXCalcCurrency(typeof(SOSiteStatusSelected.curyInfoID), typeof(SOSiteStatusSelected.baseUnitPrice))]
[PXUIField(DisplayName = "Last Unit Price", Visibility = PXUIVisibility.SelectorVisible)]
[PXDefault(TypeCode.Decimal, "0.0")]
But I'm not sure if this is the place to do it.
Here is a screenshot of the field I want to change
You can go Organization > Organization Structure > Branches and set Decimal Precision from 2 => 3

Visual Studio 2012 - Coded UI Test Builder: Assertion Formula?

While automating testing of a website shopping experience, I am attempting to verify that the subtotal, total, and tax are calculating properly. Since the price and/or tax will change in the future, I cannot simply assert the actual price value inside the control. Instead, I would need to build a calculation based upon the controls themselves and assert that quantity multiplied by individual price for each item added together equals the subtotal, and so on.
For example, say my controls for each are named such (control names are in asterisks):
Quantity = *UIItem2Cell*
(InnerText has a Value of 2)
Individual Price = *UIItem249Pane*
(DisplayText has a value of 2.49)
Individual Product Total (price x qty) = *UIItem498Pane*
(InnerText has a Value of 4.98)
Instead of validating the values are the actual numbers, can I write an assertion formula using the identifiers as variables?
Keep in mind, I am using the Coded UI Test Builder rather than writing the code outright.
If the Individual Product Total InnerText assertion comparator is AreEqual, can the Comparison Value be something like:
UIItem2Cell-InnerText * UIItem249Pane-DisplayText
A. Is this sort of formula possible?
B. If so, how do I write it?
(Please forgive me, as I am very green when it comes to this.)
You most certainly can. First off in your app itself it would be greatly useful to use IDs on your controls so you can match on just that criteria. that way your not using calculated values for search criteria.
Now as is in your question you will need to pull those values from the cells, calculate the Value and use it in your Search Criteria
// I'd recommend trimming text values:
// depending on how tables and such are rendered you'll have extra white-space characters
var firstValue = Double.Parse(UIItem2Cell.InnerText.Trim());
var secondValue = Double.Parse(UIItem249Pane.DisplayText.Trim());
var calculatedValue = string.Format("{0,N2}%", firstValue * secondValue);
// assuming your in a web app
var totalDiv = new HtmlDiv(currentHtmlDoc);
totalDiv.SearchProperties.Add(new PropertyExpression(HtmlDiv.PropertyNames.InnerText, calculatedValue, PropertyExpressionOperator.Contains));
Assert.IsTrue(totalDiv.TryFind());
SringAssert.Contains(totalDiv.InnerText,calculatedValue);

How to calculate a price if 3 products are selected and, as a pack, they are cheaper than one at a time

I am trying to make a calculator in Excel, which should show the price of the products when the user clicks the item's checkbox.
Example + QUESTION:
If the user selects only item no 1, the price is 45$.
If the user selects only item no 2, the price is 28$.
If the user selects both item no 1 and item no 2, how do I make the price 45$?
In the formula bar I have this:
=IF(A3,45,0) + IF(G3,28,0) + IF(AND(A3,G3),45,0)
item no 1 item no 2 both items selected
But the problem is that the total price is 45 + 28 + 45.
How can I handle this? Thank you!
EDIT:
Ok, I didn't think it further, here's another situation:
My price calculator looks like this:
-voice100 -broadband surf -TV varied
-voice200 -broadband play -TV extra
-voice400 -broadband power -TV max
A user can select either one product, or a 2-pack (broadband + TV) or a 3-pack (voice+BB+TV).
Is there any source that could teach me how to do this in excel? (I'll use SpreadSheet Converter to make it HTML/PHP) I want to implement it on a website so that a user can choose his own combination of services and then call me when he's happy with what he chose.
Thank you!
This one works:
=IF(AND(A3,G3),45,IF(A3,45,IF(G3,28,0)))

Resources