You are viewing limited content. For full access, please sign in.

Question

Question

How to erase data from field hidden ?

asked on April 22, 2014 Show version history

Hi everybody!

 

I have some trouble using a field hidden.

 

If i make a mistake (for exemple i wrote something in the field "Nom"),

 

Then, i hide the field using a Radio button (hide "Nom" by select "Personne morale"),

 

my value is still here (in laserfiche).

 

The paper form is prescribed so i can't change anything about the template (i can't delete any fields). I can't create 2 or more templates too. The best solution is to erase data.

 

How can i do for automatically erase the fields hidden?

 

Thanks for your help.
Regards.

0 0

Answer

APPROVED ANSWER
replied on April 23, 2014 Show version history

You need to be more specific with your selectors. Try this:

 

$(document).ready(function () {
    $('.radio input[value="Personne Morale"]').click(function () {
        $('.other input').val('');
    });
});

 

For this example, I added the radio CSS class to the radio button field and the other CSS class to the fields you want to clear.I recommend this instead of using the field identifiers.

 

0 0

Replies

replied on April 22, 2014

You could have your business process detect the condition and make the appropriate change.

 

Or you could use a little JavaScript:

 

$('#personnemoral').change(
    function(){
        if ($(this).is(':checked') {
            $('#nom').val('');
            $('#prenom').val('');
        }
    });

 

1 0
replied on April 23, 2014

Hi Devin,

 

thanks for your help.

I think i do something wrong because is not working.

 

1st : "Personne Physique" and "Personne Morale" are values from the same radio button (#q6), so i changed the code like this :

$('#q6').change(
	    function(){
	        if ($(this).val('Personne Morale')) {...

Nom's id = "#q9" and Prénom's id = "#q11"

 

So, this is my full code :

 

	$('#q6').change(
	    function(){
	        if ($(this).val('Personne Morale') {
	            $('#q9').val('');
	            $('#q11').val('');
	        }
	    });

I also try this one without success :

	$('#q6').change(
	    function(){
	            $('#q9').val('');
	            $('#q11').val('');
	    });

Thanks for your help.

 

Regard

0 0
APPROVED ANSWER
replied on April 23, 2014 Show version history

You need to be more specific with your selectors. Try this:

 

$(document).ready(function () {
    $('.radio input[value="Personne Morale"]').click(function () {
        $('.other input').val('');
    });
});

 

For this example, I added the radio CSS class to the radio button field and the other CSS class to the fields you want to clear.I recommend this instead of using the field identifiers.

 

0 0
replied on April 24, 2014

Yes. This is the better way to do it. I'm not sure how Forms generates the output, but are things like the ID guaranteed to be the same?

 

Writing out the full selector will be less prone to breaking if something gets shifted around.

0 0
replied on April 24, 2014 Show version history

The IDs won't change for the same form. So, the IDs you see on the CSS and JavaScript page will be those used when the form goes live. The IDs will not always be the same with different forms or copying code from one form to another. Using class-based code makes those situations much easier.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.