filter select based on selected value from another field
filter select based on selected value from another field
example
I have an editor form with several select lists, one of which has pricing options which need to be filtered, depending on the value of the item type selected
i would like to restrict the pricing options available when the item type has been selected.
(using Editor 1.3.3)
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
It sounds like you want to use the
select
field type'supdate()
method. Using this option you can change the values that are available in the list. You need to know when to update them, which would be triggered by an event handler on whatever field is causing the update - likely you might use something like:v1.4 will introduce a new
dependent
method which will make this kind of thing a bit easier.Allan
Thanks for ultrafast reply.
Will give it a try and feed back.
sorry, can't get this to work.
i have taken it back a few steps, so to start with, all i want to do is run the update method successfully.
My select lists are all loaded as follows, after initialising the datatable...
if i comment out one of these, eg the ItemSizeID and then run the update after editor is initalised
] );
then the size select list is updated, but otherwise, nothing happens.
sorry for being a noob, but i'm struggling here
I'm probably missing something, but what else were you expecting to happen?
Allan
sorry, not being clear.
if the editor list is populated from the json source, the update method doesn't do anything (or it does it before the json update)
if i comment out the json update, it works
I see, so the update is occurring before the
initComplete
function is called, and therefore when it is called it overwrites any changes that you have made?Either you could move the update into initComplete after the updates there, or disable the updates there perhaps?
Allan
Ok, i have disabled the line which populates the refsize editor field
after the initComplete block, i add
the refsize select is populated with the new values. - great
if i wrap this with some of the code you kindly supplied me with
I hoped that the refsize select would be empty of values, but populate as soon as i selected the SchoolID , but nothing happens
Can you link me to the page you are working on so I can debug it please. I'm not sure at the moment why is it not working. Is
tblitem.ItemSchoolID
a text input?Allan
Thanks Allan,
tblitem.ItemSchoolID is a select list, pulled from my json data source.
It isn't really relevant to this example, I just chose one of the select fields at random to try and get it to work.
http://test2.forthwebsolutions.com/plugins/shop/stocklist.php
I see - thanks for the link. So it isn't working at the moment as the
input
select used in the code above isn't going to find anything, since the input for that field is aselect
element.Try:
Note the change to listening for the
change
event as well.Hopefully that will do the business!
Allan
Aha, gotcha .
Appreciate your patience.
So many features, so much to learn
Thanks again