Forum OpenACS Development: Re: get category values within the form

Posted by Brian Fenton on
Hi Iuri

by sheer coincidence, I just provided an example of how to do this here

take a look and comment there if it doesn't work for you.


Posted by Iuri Sampaio on
Hi Brian,

The problem is that i am using categories and their names are set dinamically as in

foreach {category_id category_name} [documents::get_categories -package_id $package_id] {
if {[string equal $category_name "Tipo"]} {

ad_form -extend -name document_ae -form [list \
[list "cat_${category_id}:integer(select)" \
[list label "${category_name}"] \
[list options [documents::category_get_options -parent_id $category_id]] \
[list value ""] \
[list html "onChange \"document.document_ae.__refreshing_p.value='1';document.document_ae.submit();\""]

set child_id [set cat_${category_id}]

if {[exists_and_not_null child_id]} { ...

As we can see, after the field is selected the form gets refreshed.

i believe the problem ends up at making the following line to work.

set child_id [set cat_${category_id}]

That's where i get the error of "no such variable"

if i was able to assign what is inside the ad_form's variable cat_${category_id} then i could create the rest without problems

p.s. ajax is another way to do this. But i want to accomplish this way first. Then i will take a look at ajaxhelper.