Forum OpenACS Development: Re: Show/hide fields based on the different inputs

Collapse
Posted by kousalya S on
Hi Brian,

I found out another solution without using ajax and javascript.

Below is my code,

ad_page_contract {
This page allows the users to add bus tickets.
} {
{sample_id:integer 0 }
{contact_id ""}
{samplenew: ""}
{time: ""}
{sector: ""}
{form_mode "edit" }
}

---------------------------------------------------------------
# Create the Form
# ---------------------------------------------------------------

set form_id "sample"
ad_form -name sample -export {user_id package_id} -mode $form_mode -form {
object_id:key
{sample_nr:text(text),optional {label "Sample Nr" } }
{contact_id:text(select),optional {label "Type"} {options { {"type1" "1"} {"type2" "2"} {"type3" "3"} } }
{html { onchange "document.sample.__refreshing_p.value='1';document.sample.submit()" } }}
{enquiry_nr:text(select),optional {label "Enquiry"} {options { { "Select" "" } [db_list_of_lists sql "
select enquiry_nr, enquiry_id from im_enquiry "] } } }
}

set samplenew[list]

if { $contact_id == "1" } {
lappend samplenew {nr:text(text),optional {label "Nr"}}
} elseif { $contact_id == "3" } {
lappend samplenew {time:text(text),optional {label "Time"}}
} else {
lappend samplenew {nr:text(text),optional {label "Nr"}}
lappend samplenew {time:text(text),optional {label "Time"}}
lappend samplenew {sector:text(text),optional {label "Sector"}}
}

ad_form -extend -name sample -form $samplenew \