there are many ways…
css: wrap it with pointer-events: none;
js: on change revert the value
$(document).ready(function() {
$(".field").change(function() {
$(this).attr("value", "150.00");
});
});
php: the safest one, on submit override the posted value using the hook before submit
Thread Starter
wci
(@wci)
Hi Erik,
Thank you for your Feedback.
Please explain how and where to place your code?
Best regards,
Alex
css you can add it into customization > personalized css
JS I could not tell you exactly how because each theme has it’s own method. usually additional js (or something like that) in your template customization or if you are using a custom template you can add this code directly into script.js
$(document).ready(function() {
$("#select_off-rate-in-percent").change(function() {
$(this).attr("value", "150.00");
});
});
PHP if you are not a coder avoid because it risks to break the site
Thread Starter
wci
(@wci)
Hi Erik, thanks again.
I would prefer to use the css method and I use a css addon to add customized css codes. Can you please provide the exact css Code I need to proceed?
For the possible Secondary approach with JS Code approach I could also use a Plugin with enable to add php codes being added to the Function.php page. Please also State what Code to add there as an alternativ way to proceed.
Many Thanks in advance.
Best, Alex
this is the css code you need but be careful because it does not provide a sufficient level of security
select#select_off-rate-in-percent {
pointer-events: none!important;
cursor: pointer;
}
as the js code you can add this code directly into the form template:
<script>$(document).ready(function() {
$("#select_off-rate-in-percent").change(function() {
$(this).attr("value", "150.00");
});
});</script>
php is a better modification, yes, but it risks breaking the site and should be done with full knowledge of what we are gonna to modify. That’s why I don’t recommend it at the moment, but if any of your users find a way to bypass it, come back here and we’ll do the php part too.
hope it help!
Thread Starter
wci
(@wci)
Hi again,
I’ve tried both of your codes and unfortunately, no one does work.
The field which shall not been changed is
b.) System Einrichtungsgebühr (einmalig)
150.00
Please use this video explainer to see what I mean.
https://www.screencast.com/t/pCurrR6x
BR, Alex
sorry but i can’t find the right select. It was “#currency” the right one to target with code, so it will be:
css
select#currency {
pointer-events: none!important;
cursor: pointer;
}
js
<script>$(document).ready(function() {
$("#currency").change(function() {
$(this).attr("value", "150.00");
});
});</script>
-
This reply was modified 2 years, 10 months ago by Erik.
Thread Starter
wci
(@wci)
Hi Erik,
thanks again for providing me the codes, BUT still it has not worked.
I now use a workaround by switching form number field to a calculated field of the “Contact Form 7 Cost Calculator” addon I use.
from
[number number-setup-rate min:150.00 max:150.00 id:currency class:required “150.00”]
to
[calculated calculated-setup-rate readonly “199-49”]
This has a read-only setting and is not changeable.
Thanks for trying to help me.
Best regards, Alex