This topic is locked

How to hide a field during edit or adding data in the form

3/2/2012 12:40:03 PM
PHPRunner General questions
I
igiacchi author

Hi guys,

to hide some fields when inserting in function of a certain value in the lookup field I found this solution in the forum.
var ctrlAttivita = Runner.getControl(pageid, 'Attivita');

var ctrlDato = "Visita";

var ctrlDato1 = "Catalogo";
ctrlAttivita.on('change', function(e){

if (this.getValue() == ctrlDato){

document.getElementById("hidediv1").style.display="none";

document.getElementById("hidediv2").style.display="none";

document.getElementById("hidediv3").style.display="none";

}

});
I need also to change the HTML using this code.

{BEGIN Importo_fieldblock}<TR id=hidediv3 class=...
This funcion run well but have some problems.

When I try to edit o view the record informations that have the I see the labels and the fields.
In fact, when I edit a field that has that particular value of the fields are not hidden.
There is an alternative to avoid even in this case that filed is invisible?
Example:

I do not need to see in the next field "AMOUNT" when I choice "VISIT" in the previous lookup field.

In this case, this code works fine.

But if I need to edit a record that has already registered with the choice "VISIT", the field "AMOUNT" is still displayed.
I hope I was clear
Many thanks in advance for your help.

C
cgphp 3/3/2012

Do you want to hide the fields when you load the edit/view page and the lookup field value is "Visita"?

I
igiacchi author 3/3/2012



Do you want to hide the fields when you load the edit/view page and the lookup field value is "Visita"?


Hi Cristian,

many thanks for your answer, yes this is the problem.

I have already discovered How I can hide the field during the adding but when I try to view or edit I see this field, the previous code run on change event but when you edit a field this event is not detected, and I need to know the content of the field in editing to hide the field, I think, but I don't know how do it.

Sorry for my continuos questions but is about 20 year that I don't write any code.

C
cgphp 3/3/2012
var ctrlAttivita = Runner.getControl(pageid, 'Attivita');

var ctrlDato = "Visita";

var ctrlDato1 = "Catalogo";
function hide_fields()

{

$("#hidediv1").hide();

$("#hidediv2").hide();

$("#hidediv3").hide();

}
function show_fields()

{

$("#hidediv1").show();

$("#hidediv2").show();

$("#hidediv3").show();

}
//check the lookup field value when you load edit/view page

if(ctrlAttivita.getValue() == ctrlDato)

{

hide_fields();

}
//check the lookup field value when you change its value

ctrlAttivita.on('change', function(e){

if(this.getValue() == ctrlDato){

hide_fields();

}

else

{

show_fields();

}

});
I
igiacchi author 3/3/2012


var ctrlAttivita = Runner.getControl(pageid, 'Attivita');

var ctrlDato = "Visita";

var ctrlDato1 = "Catalogo";
function hide_fields()

{

$("#hidediv1").hide();

$("#hidediv2").hide();

$("#hidediv3").hide();

}
function show_fields()

{

$("#hidediv1").show();

$("#hidediv2").show();

$("#hidediv3").show();

}
//check the lookup field value when you load edit/view page

if(ctrlAttivita.getValue() == ctrlDato)

{

hide_fields();

}
//check the lookup field value when you change its value

ctrlAttivita.on('change', function(e){

if(this.getValue() == ctrlDato){

hide_fields();

}

else

{

show_fields();

}

});



CLOSED
Hi Cristian,

you are gold mine, I'm so happy to have a support like this, really I've never found a similar!

My best compliments.

Have a nice day.