Forum OpenACS Q&A: Re: Newbie - How to create a drop-down list?

Posted by Daniel D on
Hello Jon,

With this sample I was able to create the drop down list. However I do have an additional problem. How it works now:

I have the first_names||' '||last_name in drop down menu. By selecting a name, I pass an object_id to the DB table "project". However, I would like to pass an additional paramater - a coresponding email to the email_sub_name in the same table...

Thank you for your time.


Here is the code I have so far:

("Maintainers" query has a column, "email". But how to pass this value to different column in project table?)

ad_page_contract {
        Simple add/edit form for d-bug_project.
} {
set user_id [ad_maybe_redirect_for_registration]
set title "Add a Project"
set maintainers [db_list_of_lists get_maintainers "SELECT first_names||' '||last_name, email, object_id FROM cc_users;"]

if {[exists_and_not_null project_id]} {
    set title "Edit a Project"

ad_form -name d-bug_project_edit -form {
        {label "Description"}
        {label "Maintainer"} { options {$maintainers} {value $object_id}}
} -select_query {
    SELECT *
    FROM  project
    WHERE  project_id = :project_id
} -new_data {
db_dml do_insert_project "
      INSERT INTO project
      VALUES      (
} -edit_data {
db_dml do_update_project "
      UPDATE project
      SET    project_id    = :project_id,
              description    = :description,
              maintainer    = :maintainer,
              email_sub_name = :email,
              creator        = :user_id
      WHERE  project_id    = :project_id"
} -after_submit {
ad_returnredirect "index"