Page 1 of 1

hide fied based on the selection of other fields

PostPosted: Wed May 30, 2012 9:00 pm
by samhans
Hai steve and friends;

I am trying to hide some of my fields upon selection of select item in some other field. i.e

suppose i have a field consumable type if some one select paper he should see only type of paper after that, if he select cartridge then he should see the printer model and
cartridge number field.

i have tried using java but not able to do it. Please some body guide through the piece of code to do this.

thanks in advance.

samhans

Re: hide fied based on the selection of other fields

PostPosted: Thu May 31, 2012 2:15 am
by Jean
Hi Samhans,
You have to use javascript (http://xataface.com/documentation/how-to/custom_javascripts) a bit like this :
Code: Select all
function getSelectValue(selectId)
   var selectElmt = document.getElementById(selectId);
   return selectElmt.options[selectElmt.selectedIndex].value;
}
function hide (selectId){
if (getSelectValue(selectId)=='this'){
myfield.setAttribute("style","display:none;");
}
}

In your fields.ini, you add :
Code: Select all
widget:atts:onchange="getSelectValue('myselectlist')"


Cheers

Jean

Re: hide fied based on the selection of other fields

PostPosted: Thu May 31, 2012 9:59 am
by samhans
thanks jean for your answer.
a little clarification on the javacode. where is the select list be defined in the code. and mostly i want all the other field should hide by default and necesary field could be shown on demand.
please elaborate the use of code

samhans

Re: hide fied based on the selection of other fields

PostPosted: Thu May 31, 2012 10:47 am
by Jean
Samhans,
In fact you want to build a dynamic select box like here ? http://xataface.com/wiki/Dynamic_select_boxes

Jean