hide fied based on the selection of other fields

A place for users and developers of the Xataface to discuss and receive support.

hide fied based on the selection of other fields

Postby samhans » Wed May 30, 2012 9:00 pm

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
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am

Re: hide fied based on the selection of other fields

Postby Jean » Thu May 31, 2012 2:15 am

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
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: hide fied based on the selection of other fields

Postby samhans » Thu May 31, 2012 9:59 am

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
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am

Re: hide fied based on the selection of other fields

Postby Jean » Thu May 31, 2012 10:47 am

Samhans,
In fact you want to build a dynamic select box like here ? http://xataface.com/wiki/Dynamic_select_boxes

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved