title: Classic ASP bind input to variable
body: <p>I am more of a .Net guy, but the site I currently work on has some legacy Classic ASP pages lying around. In one of the forms we have a couple of hidden inputs that get set to variables created and set by some VBScript at the beginning of the page like so:</p>
  
  <pre><code>&lt;input name="referer" type="hidden" value="&lt;%= oReferer %&gt;" /&gt;
  </code></pre>
  
  <p>That variable is set with the following VBScript:</p>
  
  <pre><code>&lt;script type="text/vbscript" language="vbscript" runat="server"&gt;
          dim oReferer
          dim origReferer, arrRefer1, arrRefer2
          origReferer = "self"
  
          'response.Write("referer - " &amp; Request.ServerVariables("HTTP_REFERER"))
          'response.End()
          if not Request.ServerVariables("HTTP_REFERER") = "" then 
              if not Request.ServerVariables("HTTP_COOKIE") = "" then
                  if not len(Request.Cookies("OrigReferer")) &gt; 0 then
                      arrRefer1 = split(Request.ServerVariables("HTTP_REFERER"),"//")
                      if UBound(arrRefer1) &gt; 0 then
                          arrRefer2 = split(arrRefer1(1), "/")
                          if UBound(arrRefer2) &gt; 0 then
                              origReferer = arrRefer2(0)
                          end if
                      end if
                      Response.Cookies("OrigReferer") = origReferer
                      Response.Cookies("OrigReferer").Expires = DateAdd("d", 120, Date())
                  else
                      oReferer = Request.Cookies("OrigReferer")
                  end if 
              else
                  oReferer = "no cookies"
              end if
          else
              oReferer = "self"
          end if
  &lt;script&gt;
  </code></pre>
  
  <p>This code works all fine, most of the time. When I try using this code in a newer version of the form I am getting two issues. First the input itself does not get set at all. I am not sure why as the code does have a default so it should always at least be "self". Second issue is that the original code, not written by me, worked using &lt;% oReferer %> to set the value. When I do that now I get a VBScript error, "type mismatch". </p>
  
  <p>Like I said I am a .Net guy and solving this in .Net is not a problem. I don't know Classic ASP as well and I am stumped. I would love to change to .Net but can't for this particular form right now, so any help to figure this out would be great. </p>