Hi there,
I've a little question (a few...) about dropdown field, the events feature and syntax.
In my form, I need to set several thing, maybe a bit tricky for me (coding JS or PHP isn't my first profession...face-meh-blank)
1. Classic things I can do easily thanks to CF : create PDF with the data (hum got some problems w/ tcpdf and text formatting but it will do), save it on the server, email the data and attach the PDF. Hooray!
2. In details, the tricky part for me... : An dropdown item will set a quantity of persons ({nb}).
- This field is required to calculate a price ({nb} * constant) and the result will be recorded (I've an old javascript a friend shows me 3 or 4 years ago... But I'm sure there is something more up to date)
- I need this variable to enable / disable the same quantity of required fields (container {pers} w/ 2 text input - first name / name).
i.e. if the user sets 2 persons, I need 2 containers (ie. pers1, pers2...). 3 persons = 3 containers...
With a quantity of 2, it's easy to set the event settings, but I need at least 5 persons.
Q1 : So, is there a simple way or a syntax to set the same event (enable/disable or show/hide) for more than 1 field ? i.e.
On = 2 => ENABLE => Field PERS1 & PERS2
On = 2 => DISABLED => Field PERS3 & PERS4 & PERS5...
Q2 : If a required field is disabled, the validation script will pass through this element if empty ?
Q3 : In the same order, if a required field is set on "parent hidden", what's the effect with validation ?
Q4 : For the script I'll use to calculate the final price, it's working but if a pro could give me his discharge :
Many thanks for your advices!
Germain.
I've a little question (a few...) about dropdown field, the events feature and syntax.
In my form, I need to set several thing, maybe a bit tricky for me (coding JS or PHP isn't my first profession...face-meh-blank)
1. Classic things I can do easily thanks to CF : create PDF with the data (hum got some problems w/ tcpdf and text formatting but it will do), save it on the server, email the data and attach the PDF. Hooray!
2. In details, the tricky part for me... : An dropdown item will set a quantity of persons ({nb}).
- This field is required to calculate a price ({nb} * constant) and the result will be recorded (I've an old javascript a friend shows me 3 or 4 years ago... But I'm sure there is something more up to date)
- I need this variable to enable / disable the same quantity of required fields (container {pers} w/ 2 text input - first name / name).
i.e. if the user sets 2 persons, I need 2 containers (ie. pers1, pers2...). 3 persons = 3 containers...
With a quantity of 2, it's easy to set the event settings, but I need at least 5 persons.
Q1 : So, is there a simple way or a syntax to set the same event (enable/disable or show/hide) for more than 1 field ? i.e.
On = 2 => ENABLE => Field PERS1 & PERS2
On = 2 => DISABLED => Field PERS3 & PERS4 & PERS5...
Q2 : If a required field is disabled, the validation script will pass through this element if empty ?
Q3 : In the same order, if a required field is set on "parent hidden", what's the effect with validation ?
Q4 : For the script I'll use to calculate the final price, it's working but if a pro could give me his discharge :
<script>
function calculate() {
var nb = document.getElementById('nb').value;
var result = document.getElementById('total');
var myResult = nb * 400;
total.value = myResult;
}
</script>
<label for="nb">Nombre de participants</label>
<select id="nb" onchange="calculate()">
<option value="">nb ?</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
Total à payer en euros :<input id="total" type="text" name="total" value="" size="6" readonly>
Many thanks for your advices!
Germain.
Hi Germain,
The simplest way to do this is with Custom JavaScript. Add all five sets of inputs to your form - possibly putting each row in a separate container - hide all but the first, then use JavaScript to un-hide the appropriate number.
You will probably need more help from your friend to write the code, though it is quite simple to do.
Bob
The simplest way to do this is with Custom JavaScript. Add all five sets of inputs to your form - possibly putting each row in a separate container - hide all but the first, then use JavaScript to un-hide the appropriate number.
You will probably need more help from your friend to write the code, though it is quite simple to do.
Bob
This topic is locked and no more replies can be posted.