Hi
I have the field Category, SubCategory, and ProductType in select
boxes
When a category is selected corresponding subcategory is selected and
its corresponding product type is to be selected…But i have when a
category selected subcategory selected and its produt type selecetd for
first time…But after observerfield update div as follow my product type
not updated code as below
Category
<%= select( “sd_ticket”, “service_desk_category_id”,
ServiceDeskCategory.find(:all).collect {|p| [ p.name, p.id ] }) %>
Hi
I could not solve this yet…When I click on the sub category select
box corresponding product types are listed on Product type select
box…But when I click on the ategory select box corresponding
Subcategory are selected in the subcategory select boxe But then its
product types are not filled in ProductType select box…How can I solve
this…Please help
Hi
I could not solve this yet…When I click on the sub category select
box corresponding product types are listed on Product type select
box…But when I click on the ategory select box corresponding
Subcategory are selected in the subcategory select boxe But then its
product types are not filled in ProductType select box…How can I
solve
this…Please help
It’s probably to do with the observer still observing the ‘old’ select
box that you have since replaced. You can probably make your life
easier by using an onselect rather than the whole observe_field thing.
Hi
Thanks for your eply…Could you please explain little bit more.I did
not understand .
I’m speculating that the observe_field is still observing the replaced
select, not it’s replacement and saying that you could use an
onchange instead of an observer
Hi
I am solving as you said.Only one more thing to solve.I have two js
function like
function set_sub_category(val)
{
new Ajax.Updater(‘sub_category_container’,
‘/popup/prepare_sub_category’, {
parameters: { category_id: val},
onSuccess: javascript:set_product_type(5);
});
}
function set_product_type(val)
{
alert(val);
new Ajax.Updater(‘product_type_container’,
‘/popup/prepare_product_type’, {
parameters: { sub_category_id: val}
});
}
Here how can I call set_product_type function onSuccess of
set_sub_category?Also how can i return value from
/popup/prepare_sub_category action to set_sub_category?
Hi
Thanks Its working…May I ask you one more?.Here I am just blindly
passing 5 to set_product_type…Actually it is the
service_desk_sub_category_id…How can I access this from response?
Hi
Thanks Its working…May I ask you one more?.Here I am just blindly
passing 5 to set_product_type…Actually it is the
service_desk_sub_category_id…How can I access this from response?
$F(‘service_desk_sub_category_id’) assuming you mean the value of the
input item with that id
}
That’s not syntactically correct: the parameter to onSuccess should be
a function , eg onSuccess: function(response){set_product_type(5)}
The response rendered by the server is available as
response.responseText.
Here when I gave
onSuccess: function(response){javascript:alert(response.responseText)
I get
<select id=“sd_ticket_service_desk_sub_category_id”
name=“sd_ticket[service_desk_sub_category_id]”
onchange=“javascript:set_product_type(this.value);”
Category4-1
Category4-2
Category4-3
How can I access the value 9 (which is what I need in this case)…That
solves my problem
Here when I gave
onSuccess: function(response){javascript:alert(response.responseText)
stop sticking in those javascript: things, theu’re completely
superfluous at the best of times and syntatically invalid in the one
above. Also, why bother messing around with the ajax response when you
can just look at the form element?
($F(‘sd_ticket_service_desk_sub_category_id’))