Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

How to create a script to check if all values of a group of fields are entered. 18.03.2017 17:58

Hi,

I am trying to create a script to check if all values of certain fields are entered.
I tried to used PHP, but I cannot get it to work:
$fw1 = floatval($w1);
$fh1 = floatval($h1);
$ft1 = floatval($t1);
if (( $fw1 != 0 ) Xor ( $fh1 != 0 )) or (( $fw1 != 0 ) Xor ( $ft1 != 0 )) or (( $fh1 != 0 ) Xor ( $ft1 !=0 )) {
echo 'Please enter all three dimensions';
}

In essence, what I am trying to do is in case the user has entered values to some of the 3 fields w1:Width, h1:Height, or t1:Thickness, I would like the script to ask them to enter all dimensions, so it should not finish the calc but should wait for the data entry. In case they did not enter any if the values, the script should not ask them anything and the calculation should take place.

Thank you in advance.

Re: How to create a script to check if all values of a group of fields are entered. 20.03.2017 20:35

Hi,
not sure if creating the validation at server side would be the better approach, we'd suggest instead to add some code at the javascript tab (before calculate execution tab), so the calculation won't be launched at all until your conditions are met:

var w1=CB("input[fldname=w1]").val();
var h1=CB("input[fldname=h1]").val();
var t1=CB("input[fldname=t1]").val();

//if any of the fields is not empty
if(w1!=""||h1!=""||t1!=""){

//then if any if the fields is empty
if(w1==""||h1==""||t1==""){

//message and abort calculation
alert('Please enter all three dimensions');
return (-1);
}

}


If creating the php code is a must for your specific case you should return the message 'inside' any result, so users can see it at the page, you can use any output variable and/or any inline result to print it inside the input form. So, intead of the 'echo' function, you should write something like

$mymessage="Please enter all three dimensions";


And then print ##mymessage## at the output form.

Please let us know if you need further help.
Regards
Moonsoft Team
www.moonsoft.es

Re: How to create a script to check if all values of a group of fields are entered. 21.03.2017 16:16

Thank you very much. I went with the javascript approach.
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Our clients' feedback