Reputation: 141
I am trying to implement shopping cart for my Yii2 site. There are N calculation forms depending on how many products user put in a cart.
<form class="calculator" id="calc1">
<div id="calc_left_half">
<br>
<input type="number" step="0.01" class="calculation_input" id="regular_input_1" name="regular_input" value="0" onkeyup="order()" onchange="order()"> Put A value
<br>
<input type="number" step="0.01" class="calculation_input" id="angular_input_1" name="angular_input" value="0" onkeyup="order()" onchange="order()"> Put B value
<br>
</div>
<div id="calc_right_half">
<span class="order"> SUM: <span class="color_result result" id="result_color_1">0</span> $<br>
</div>
</form>
<form class="calculator" id="calc2">
<div id="calc_left_half">
<br>
<input type="number" step="0.01" class="calculation_input" id="regular_input_1" name="regular_input" value="0" onkeyup="order()" onchange="order()"> Put A value
<br>
<input type="number" step="0.01" class="calculation_input" id="angular_input_1" name="angular_input" value="0" onkeyup="order()" onchange="order()"> Put B value
<br>
</div>
<div id="calc_right_half">
<span class="output"> SUM: <span class="color_result result" id="result_color_1">0</span><br>
</div>
</form>
<a id="order" class="btn btn-success btn-send cart-button" href="index.php?r=site/create-pdf?>"><b>ORDER</b></a>
Function order() makes some calculation and assigns "output" span innerHtml to result. I My question is how to pass input values and "output" innerHtml value to action(site/create-pdf). I would like to create a pdf using mpdf extention with this values.
Side newbee question: Is it good idea to use json or xml for this purpose.
Thanks guys
Upvotes: 1
Views: 991
Reputation: 5485
$this->view->params['customParam'] = 'customValue'
Yii2 global variable in other actions.
Upvotes: 1