Hello
I have problem picking up form data. One of my form field is:
and another field:
I would like to pick you the currency in this way:
I have tried many other ways but I don't seem to succeed. I am not a php expert please help.
thanks
Ron
I have problem picking up form data. One of my form field is:
<select id="currency" name="currency" required="true" style="font-family:Verdana, Geneva, sans-serif; width:480px; font-size:20px; height:40px; border:1px solid #999;" onChange="change_selection();">
<option value="0" selected="selected" >Select Your Currency</option>
<option id="9" value="9">Price quote in USD.</option>
<option id="10" value="10">Price quote in EUR.</option>
<option id="11" value="11">Price quote in UAH.</option>
<option id="12" value="12">Price quote in GBP.</option>
</select>
and another field:
<input type="checkbox" id="afkv" value="1" name="afkv" />
I would like to pick you the currency in this way:
< ?php
if (!empty($form->data['afkv'])) {
print("\n {$prices['currency'.'_afkv']}");
$totals -= $prices['currency'.'_afkv'];
}
? >
I have tried many other ways but I don't seem to succeed. I am not a php expert please help.
thanks
Ron
Hi Ron,
Please explain what you are trying to do here . . . I can't work it out from your PHP snippet.
Bob
Please explain what you are trying to do here . . . I can't work it out from your PHP snippet.
Bob
Thanks for your reply bob
I want to get the value of the currency. I would like to print the full value, example if the currency is 10. then I should get "10_afkv" as output from this code.
thanks again
Ron
I want to get the value of the currency. I would like to print the full value, example if the currency is 10. then I should get "10_afkv" as output from this code.
thanks again
Ron
Then maybe:
echo $form->data['currency']."_afkv";
I was travelling so is the delay in replying . I am sorry I have not been able to explain properly. In fact this code picks prices from a dynamic array. And it don't seem to work.
The choice of prices is as per the fields in my first post in this thread.
Thanks for the help Max.
The choice of prices is as per the fields in my first post in this thread.
< ?php
if (!empty($form->data['afkv'])) {
print("\n {$prices['currency'.'_afkv']}");
$totals -= $prices['currency'].'_afkv';
}
? >
Thanks for the help Max.
Further to my post ( as there is no edit function on this forum like earlier now) I would like to add that if you could help me in this code:
This has errors and I ma unable to fix.
Thanks
Ron
< ?php
if (!empty($form->data['currency'].'_afkv')){
print("\n {$prices['currency'.'_afkv']}");
$totals -= $prices['currency'.'_afkv'];
}
? >
This has errors and I ma unable to fix.
Thanks
Ron
Hi Ronn,
I cannot understand what you are trying to do here. Please explain in detail with examples of the output.
Max's example will give you the string 10_afkv that you asked for. But your code snippets use $totals -= $prices['currency'.'_afkv']; and -= only makes sense if you are working with numbers, it won't work with strings.
Bob
I cannot understand what you are trying to do here. Please explain in detail with examples of the output.
Max's example will give you the string 10_afkv that you asked for. But your code snippets use $totals -= $prices['currency'.'_afkv']; and -= only makes sense if you are working with numbers, it won't work with strings.
Bob
Thanks bob for coming to my rescue.
This code picks up the value selected as per my first post in this thread. It does use 10_afkv but it fetches value from a price array to subtract from a main value. This is part of a custom code that I need to output.
I hope I am able to explain.
Ron
This code picks up the value selected as per my first post in this thread. It does use 10_afkv but it fetches value from a price array to subtract from a main value. This is part of a custom code that I need to output.
< ?php
if (!empty($form->data['currency'.'_afkv'])){
print("\n {$prices['currency'.'_afkv']}");
$totals -= $prices['currency'.'_afkv'];
}
? >
I hope I am able to explain.
Ron
This is the array from where it picks up prices:
Hope I am able to explain
< ?php
/* IMPORTANT NOTE
Numbers denoting the corresponding currencies:
usd = 9
eur = 10
uah = 11
inr = 12
bhd = 13
sar = 14
gbp = 15
rub = 16
*/
$prices = array(
"9_afkv" => 1200,
"10_afkv" => 950,
"13_afkv" => 455,
"14_afkv" => 4500,
"15_afkv" => 785,
"11_afkv" => 9600,
"12_afkv" => 60000,
);
? >
Hope I am able to explain
Hi Ronn,
Let me try and put all these pieces together.
In the form HTML you have a drop-down select box and a check-box like this:
When the form is submitted, if the checkbox is checked you want to look up the value from the array and subtract it from the total:
Bob
Let me try and put all these pieces together.
In the form HTML you have a drop-down select box and a check-box like this:
<select id="currency" name="currency" required="true" onChange="change_selection();" >
<option value="" selected="selected" >Select Your Currency</option>
<option id="9" value="9">Price quote in USD.</option>
<option id="10" value="10">Price quote in EUR.</option>
<option id="11" value="11">Price quote in UAH.</option>
<option id="12" value="12">Price quote in GBP.</option>
</select>
<input type="checkbox" id="afkv" value="1" name="afkv" />
When the form is submitted, if the checkbox is checked you want to look up the value from the array and subtract it from the total:
<?php
if ( isset($form->data['afkv']) && $form->data['afkv'] && $form->data['currency'] ) {
$prices = array(
"9_afkv" => 1200,
"10_afkv" => 950,
"13_afkv" => 455,
"14_afkv" => 4500,
"15_afkv" => 785,
"11_afkv" => 9600,
"12_afkv" => 60000,
);
$temp = $form->data['currency'].'_afkv';
if ( in_array($temp, $prices) ) {
$total -= $prices[$temp];
}
}
?>
Bob
Thanks for the help Bob,
I tried the code it dosn't seem to work. This code works:
But I want to have the possibility of adding other currencies too. Here I can work with only one currency. I have added a drop-down with a choice of currencies.
Thanks
Ron
I tried the code it dosn't seem to work. This code works:
< ?php
$path = JPATH_ROOT.DS.'components'.DS.'com_data'.DS;
require_once($path.'prices.php');
if (!empty($form->data['afkv'])) {
print("\n {$prices['10_afkv']}");
$totals -= $prices['10_afkv'];
}
? >
But I want to have the possibility of adding other currencies too. Here I can work with only one currency. I have added a drop-down with a choice of currencies.
Thanks
Ron
I tried doing something like this:
Bet it does not work either.
Ron
< ?php
$path = JPATH_ROOT.DS.'components'.DS.'com_data'.DS;
require_once($path.'prices.php');
if (!empty($form->data['currency'.'_afkv'])) {
print("\n {$prices['currency'.'_afkv']}");
$totals -= $prices['currency'.'_afkv'];
}
? >
Bet it does not work either.
Ron
Hi Ron,
It's impossible to help you if the description of what you want changes each time that you post.
If something doesn’t work then please explain exactly what doesn’t work and use extra debug code to see what is happening.
Bob
It's impossible to help you if the description of what you want changes each time that you post.
If something doesn’t work then please explain exactly what doesn’t work and use extra debug code to see what is happening.
Bob
Sorry for the confusion Bob,
I just tried to mention what all I tried. As I mentioned this code works:
But I can work only with one currency in this code. I want to have the possibility of using multiple currencies so I tried the undermentioned code:
But I failed. I cannot debug the code and I am not a PHP expert so I have limitations. Sorry if I bothered you about it.
Ron
I just tried to mention what all I tried. As I mentioned this code works:
< ?php
$path = JPATH_ROOT.DS.'components'.DS.'com_data'.DS;
require_once($path.'prices.php');
if (!empty($form->data['afkv'])) {
print("\n {$prices['10_afkv']}");
$totals -= $prices['10_afkv'];
}
? >
But I can work only with one currency in this code. I want to have the possibility of using multiple currencies so I tried the undermentioned code:
< ?php
$path = JPATH_ROOT.DS.'components'.DS.'com_data'.DS;
require_once($path.'prices.php');
if (!empty($form->data['currency'.'_afkv'])) {
print("\n {$prices['currency'.'_afkv']}");
$totals -= $prices['currency'.'_afkv'];
}
? >
But I failed. I cannot debug the code and I am not a PHP expert so I have limitations. Sorry if I bothered you about it.
Ron
Hi Ron,
I'm sorry but I still have no idea what it is that you are trying to do or what the problem is with the version I posted for you :-(
Bob
I'm sorry but I still have no idea what it is that you are trying to do or what the problem is with the version I posted for you :-(
Bob
Thanks for all the help Bob,
But the code you gave me does not work. I get no out put what so ever with it. I think I have limitation in my approach. I am not able to explain my position well.
Sorry for all the confusion I created in this thread,
Ron
But the code you gave me does not work. I get no out put what so ever with it. I think I have limitation in my approach. I am not able to explain my position well.
Sorry for all the confusion I created in this thread,
Ron
Bob
I wanted to know is there an option in chronoforms to send an email as per a selection of a dropdown.? Maybe I could make different replies as per selection.
Thanks
Ron
I wanted to know is there an option in chronoforms to send an email as per a selection of a dropdown.? Maybe I could make different replies as per selection.
Thanks
Ron
Hi Ron,
If you have a different question, please post it in a new thread. The Dynamic To options in the email action work the same as they always have.
Bob
If you have a different question, please post it in a new thread. The Dynamic To options in the email action work the same as they always have.
Bob
Bob
I modified the code slightly and now it works. But it does not subtract
Can you please help.
Thanks
Ron
I modified the code slightly and now it works. But it does not subtract
< ?php
if ( isset($form->data['afkv']) && $form->data['afkv'] && $form->data['currency'] ) {
$temp = $form->data['currency'].'_afkv';
print("\n {$prices[$temp]}");{
$total -= $prices[$temp];
}
}
? >
.
Can you please help.
Thanks
Ron
This topic is locked and no more replies can be posted.