Server Side Includes - Problem passing variables

Results 1 to 2 of 2

Thread: Server Side Includes - Problem passing variables

  1. #1
    Join Date
    Dec 1969

    Default Server Side Includes - Problem passing variables

    I want to use a server side include for accessing some frequently used<BR>functions. I am having problem in passing the arguments to the functions in<BR>the include file.<BR>Error is type mismatch.<BR>Here is the sample of the code i am using .<BR><BR>&#060;%@LANGUAGE="VBSCRIPT"%&#062;<BR>&#0 60;!-- INCLUDE FILE="" --&#062;<BR>&#060;%dim mthfld,mthtab,sqlstr,rs1,rs2,conn,grpname,mth,totv ol,vol,objmth<BR>mth=request.form("acmth")+request .form("acyr")<BR>mthfld=cshmmth(mth)<BR>mthtab=csh myr(mth)<BR>response.write mthfld<BR>response.write mthtab%&#062;<BR><BR>I have a html page with a form with to drop down lists to select "Acmth" &<BR>"ACYr" (basically a month field and a year field) and these values are<BR>posted to above asp page.<BR><BR>The include file contains following code.<BR>--<BR>&#060;%function cshmmth(acmth)<BR>dim mmth,mthfld<BR>mmth=left(acmth,2)<BR>select case mmth<BR>case 3<BR> mthfld="cf_mar_vol"<BR>case 4<BR> mthfld="cf_apr_vol"<BR>case 5<BR> mthfld="cf_may_vol"<BR>case 6<BR> mthfld="cf_jun_vol"<BR>case 7<BR> mthfld="cf_jul_vol"<BR>case 8<BR> mthfld="cf_aug_vol"<BR>case 9<BR> mthfld="cf_sep_vol"<BR>case 10<BR> mthfld="cf_oct_vol"<BR>case 11<BR> mthfld="cf_nov_vol"<BR>case 12<BR> mthfld="cf_dec_vol"<BR>case 01<BR> mthfld="cf_jan_vol"<BR>case 02<BR> mthfld="cf_feb_vol"<BR>end select<BR>cshmmth=mthfld<BR>end function<BR><BR>function cshmyr(acmth)<BR>dim mmth,myr,tabyr,mlyr,mnyr<BR>mmth=left(acmth,2)<BR> myr=right(acmth,2)<BR>mlyr=myr-1<BR>mnyr=right(myr+1,2)<BR>select case mmth<BR>case 1,2,3<BR> tabyr=mlyr&myr<BR>case 4,5,6,7,8,9,10,11,12<BR> tabyr=myr&mnyr<BR>end select<BR>cshmyr=tabyr<BR>end function%&#062;<BR>--<BR><BR>When i pass a numeric value to one of these function they work . eg if I<BR>say<BR>mthfld=cshmmth(111999) ,<BR>it works but if i assign the same value to variable mth and say<BR>mthfld=cshmmth(mth) , it won&#039t work . Out put shows a error message "Type<BR>mismatch . line no nn "<BR><BR>I have for now bypassed this problem by copy the functions into each of the<BR>ASP page which uses these functions. This way it works fine.<BR><BR>I have also created an ASP component in VB for these functions and tried<BR>with arguments declared alternately as long,string and variant . But the<BR>same error occurs even then .<BR><BR>I badly need to solve this problem .<BR><BR>Thanks<BR><BR>Sridhar<BR><BR>

  2. #2
    Pheonix Guest

    Default RE: Server Side Includes - Problem passing variabl

    Sridhar,<BR><BR>Change your code in the following line from:<BR><BR>mth=request.form("acmth")+request.for m("acyr")<BR><BR>To:<BR><BR>mth=request.form("acmt h") & request.form("acyr")<BR><BR>Let me know if that helps,<BR>Phoenix

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts