if field is hidden, then...

enzo.orsi 05 Nov, 2015
I need a way to manage hidden fields.
Is there any php code like

If field1 is hidden (or parent hidden) then field1.value = ""

Thank you!
GreyHead 05 Nov, 2015
Hi enzo.orsi,

You can do that with JavaScript, though there doesn't seem to me to be a simple way to trigger it using the ChronoForms events code.

Bob
enzo.orsi 05 Nov, 2015
It does not matter to have it immediately in the form, I need to reset the value after submit, when I need to write values in database.
Any suggestion about the js?

Thank you Bob!
GreyHead 05 Nov, 2015
Hi enzo.orsi,

How would you know that the element had been hidden after the form is submitted?

Bob
enzo.orsi 05 Nov, 2015
Yes, that's true🙂
And what's about immediately before submit?
Any idea about how should js be?
enzo.orsi 25 Jan, 2016
I was trying to load a JS like this (button1 is the name of the input button of my form and R0002 is the text field that I want to reset)
But it is still not working...

button1.addEventListener("click", function() {
    if(document.getElementById("R0002").type == "hidden") {
          document.getElementById("R0002").value="" ;
    }
}, false);
enzo.orsi 25 Jan, 2016
I found the solution.

In the button extra params:
onclick=EO_check_hidden()


In a JS loader:
function EO_check_hidden() {
if(document.getElementById("R0001") != null && typeof(document.getElementById("R0001") != 'undefined')) { if(document.getElementById("R0001").offsetWidth == 0) { document.getElementById("R0001").value=null ; } } }
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger