Internet is growing Every Seconds :: Industry is growing Every Year

Sunday, February 20, 2005

ASP Function : cbo_lst_vluId_showName_nb

Description

This method is used to Fill the combo box when the page is refreshed
and its maintain the same data.

This accepts 10
TableName,cmbovaluefld,comboshow,orderby_name,do_sub,slt_fld_id,wer_cond,wer_KeyName,wer_KeyValue,wer_datatype
TableName - Name of the Table name
cmbovaluefld - name of the Combobox value < option value=
cmbovaluefld >
comboshow -name of the Combobox Showing Field < option value=
cmbovaluefld > comboshow < / option >
orderby_name -display the Names in Order by in SQL Query
do_sub - yes or no wheater its submit or not
slt_fld_id - if the page is submited the submited value is selected
after the refreshing
wer_cond - if the submited value is checked any ohter values (its
true or false)
wer_KeyName -Name of the Field
wer_KeyValue-value of the field
wer_datatype- Datatype of the Fieldname.

ASP Code


Public Function
cbo_lst_vluId_showName_nb(TableName,cmbovaluefld,comboshow,orderby_name,do_sub,slt_fld_id,wer_cond,wer_KeyName,wer_KeyValue,w

er_datatype)
ColValue=""
ck_val_nb=1
set cbo_rs = Server.CreateObject("ADODB.RecordSet")
if wer_cond="yes" and wer_datatype="I" then
sql = "select "&cmbovaluefld&" as optvalue , "&comboshow&" as
optshow from "&TableName& " where "&wer_KeyName& "="&wer_KeyValue &"
ORDER BY "&orderby_name&""
elseif wer_cond="yes" and wer_datatype="S" then
sql = "select "&cmbovaluefld&" as optvalue , "&comboshow&" as
optshow from "&TableName& " where "&wer_KeyName& "='"&wer_KeyValue
&"'" &" ORDER BY "&orderby_name&""
else
sql = "select "&cmbovaluefld&" as optvalue , "&comboshow&" as
optshow from "&TableName& " ORDER BY "& orderby_name&""
end if

cbo_rs.open sql,Con
if not cbo_rs.eof then
while not cbo_rs.EOF

if do_sub="no" then
if ck_val_nb=1 then
ck_nb_sel_val="Selected"
else
ck_nb_sel_val=""
end if
ColValue=ColValue & " < OPTION value="&cbo_rs("optvalue") &"
"& ck_nb_sel_val&" > "& cbo_rs("optshow") &" < / option > "
ck_val_nb=ck_val_nb+1

elseif do_sub="yes" and slt_fld_id="" then
if ck_val_nb=1 then
ck_nb_sel_val="Selected"
ColValue=ColValue & " < OPTION value=selectanyone selected >
Select any one < /option > "
ck_nb_sel_val=""
else
ck_nb_sel_val=""
end if
ColValue=ColValue & " < OPTION value="&cbo_rs("optvalue") &"
"& ck_nb_sel_val&" > "& cbo_rs("optshow") &" < / option > "
ck_val_nb=ck_val_nb+1

elseif do_sub="yes" and slt_fld_id < > "" then
if ck_val_nb=1 and cint(slt_fld_id)=cint(cbo_rs("optvalue")) then
ck_nb_sel_val="Selected"
ck_val_nb=ck_val_nb+1
else
ck_nb_sel_val=""
end if
ColValue=ColValue & " < OPTION value="&cbo_rs("optvalue") &"
"& ck_nb_sel_val &" > "& cbo_rs("optshow") &" < /option > "
end if
cbo_rs.MoveNext
wend
else
ColValue=ColValue & " < PTION selected value=0 > Datas Not
Available < option "
end if
cbo_rs.close
set cbo_rs=Nothing
cbo_lst_vluId_showName_nb=ColValue
End Function





< TR > < TD > Project Name < /td > < TD colspan=3 >
< SELECT NAME="project" onchange="proj_submit()" >
< %
slt_fld_id=trim(Request.Form("project"))
dosub="yes"
% >
<
%=cbo_lst_vluId_showName_nb("Tbl_Proj_Master","Project_ID","Project_Name","Project_Name",dosub,slt_fld_id,0,0,0,0)%
>
< /SELECT > < /TD >
< /tr >








< tr > < TD > Employee Name < /TD > < TD colspan=3 >

< SELECT name="empid" style="width: 250px;" onchange="proj_submit()"
>
< %
empid=trim(request.Form("empid"))
dosub="yes"
wer_cond="yes"
wer_KeyName="Project_ID"
if slt_fld_id="" then slt_fld_id=0
wer_KeyValue=slt_fld_id
wer_datatype="I"
slt_fld_id=empid
dim chkvalue_nb
chkvalue_nb=0
% >
<
%=cbo_lst_vluId_showName_nb("Tbl_Emp_Master","Emp_ID","emp_name","emp_name",dosub,slt_fld_id,wer_cond,wer_KeyName,wer_KeyValu

e,wer_datatype)%
>
< /SELECT >
< /TD > < /TR >