classic asp - call a vbscript function from a button without page reload?

Hello: OK, I know I'm not using the lastest and greatest tools but there's a reason for that! I have a legacy classic asp page loading. It uses a querystring parameter, and for my own reasons which are hard to explain to you I don't want to reload the page again.

I'm trying to find a way to update variables on the page by calling a vbscript function 'labelOpen' which reads a database then updates the variables displayed.

What I need to do is call the labelOpen function from a button (or even better onChange of two radio buttons "English" or "French" then update the 'LabelGet[1]' variable and reload the <!-- #INCLUDE file="includes/customlogin/2012studentlogin.asp" -->.

I know I'm paddling upstream. Any way to do this?

TIA
Ron


<%@LANGUAGE="VBSCRIPT"%>
<!-- #INCLUDE file="online/simplytracking/includes/clsLayout.asp"-->
<!-- #INCLUDE file="includes/settings2.asp" -->
<%

      Dim strCompanyLoginName, strClientID, strVersion, strLanguageCode, SqlQuery, obj, rs, ptr


<!-- LABEL CODE BEGIN --->

      Dim rsLabels

      Public Sub labelOpen ( LabelPage, LabelLang )
            Set      rsLabels = Server.CreateObject("ADODB.Recordset")
            rsLabels.ActiveConnection      = objConnection
            rsLabels.CursorLocation = 3
            rsLabels.Open "SELECT * FROM Labels WHERE FileName='" & LabelPage & "' AND LanguageCode='" & LabelLang & "'"
      
      End Sub

      Public Sub LabelClose
            rsLabels.close
            Set rsLabels = Nothing
      End Sub

      Public Function labelGet(label_id)
            On Error Resume Next
            If not rsLabels.EOF Then
                  rsLabels.MoveFirst
                  rsLabels.Find "LabelId = " & label_id
                  If rsLabels.EOF Then
                        labelGet = "|Label Missing|"
                  Else
                        labelGet = rsLabels.Fields("Text")
                  End If
            Else
                  labelGet = "|LabelPage Missing|"            
            End if
            If Err <> 0 Then
                  labelGet = "| labelGet Error: " & Err.Num & " / " & Err.Description &" |"
            End If
            On Error Goto 0 ' disables error handling enabled at start of function
      End Function

<!-- LABEL CODE END --->



      strCompanyLoginName = Request.Querystring
      
      
      If Len(strCompanyLoginName) > 0 Then
      ptr = InStr(strCompanyLoginName,"&lc=")
      
      If ptr > 0 Then
            strLanguageCode = Mid(strCompanyLoginName,ptr+4,2)
            strCompanyLoginName = Mid(strCompanyLoginName,1,ptr-1)
      Else
            strLanguageCode = Null
      End If
      SqlQuery = "SELECT * FROM Companies WHERE (CustomLoginPage LIKE '%asp?" & strCompanyLoginName & "')"
    Set      obj = Server.CreateObject("ADODB.Command")
    obj.ActiveConnection = objConnection
    obj.CommandText = SqlQuery
    Set rs = obj.Execute
      If NOT rs.BOF Then
            rs.MoveFirst
            strClientID = rs.fields.Item("CompanyID")
            strVersion = Trim(rs.fields.Item("STVersion"))
            If IsNull(strLanguageCode) Then
                  strLanguageCode = rs.fields.Item("LanguageCode")
                  If IsNull(strLanguageCode) Then
                        strLanguageCode = "en"
                  Else
                        strLanguageCode = Trim(strLanguageCode)
                  End If
            End If
            Session("KCCVersion") = strVersion
            labelOpen "custom.asp", strLanguageCode
      Else
            Response.Redirect "elearning.asp"
      End If      
      
            
dim objLayout, objSecurity
Dim Title, sTCP

set objLayout = new clsLayout
set objSecurity = new clsSecurity


If Request.QueryString("refresh") <> "" Then
      call objSecurity.SignOut
      Session.Abandon
      
      Response.Redirect(Request.ServerVariables("SCRIPT_NAME"))
End IF


<html>
<head>
<title><% =labelGet(0) %></title>
<script language="JavaScript" src="online/simplytracking/includes/gen_validatorv2.js" type="text/javascript"></script>
<style type=text/css>
      A:hover { COLOR: #006699 }
      A { COLOR: #000000 }
      #TM_NOTE {
            background-color:#FFEED4;
            border: #FF9900 solid 1px;
            font-family:Verdana;
            font-size:10px;
            text-align:center;
            padding:2px;
            margin:2px;
      }
</style>
</head>
<body bgColor="#29517B" topmargin="10" leftmargin="10" marginheight="0">



<div align="left"><img src="online/logos/<%=strClientID%>logoweb.jpg" > <BR>
  <BR>
</div>

<table>
<tr>




<td>
        
<% LabelLang = "fr" %>
<% LabelPage = "custom.asp" %>

HERE I"M TRYING TO USE A BUTTON OR LINK TO CALL THE LABELOPEN FUNCTION

        <a href="#" onclick="<% call labelOpen(LabelPage,LabelLang) %>">CALL LABELOPEN FUNCTION</a>


</td>


  <td align="left"> <br>
    <div><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif" color=#FFFFFF>
      <% =labelGet(1) %>
        </FONT> </div><br>
        
  </td>
</tr>
</table>

<div align="center">
<TABLE border=0 cellpadding=0 cellspacing=0>


<!-- #INCLUDE file="includes/customlogin/2012studentlogin.asp" -->



</div>
</BODY>
KnowledgeWareAsked:
Who is Participating?
 
KnowledgeWareAuthor Commented:
I figured this out. Ajax not needed. Using string functions to read in the parameters at top of page and load the page respectively.

Ron




<form>
<% if strLanguageCode = "en" then
      dim location
      location = "custom.asp?"& strCompanyLoginName & "&lc=fr"
%>
&nbsp;&nbsp;<input type="button" value="French" onClick="document.location='<%=location%>'">

<% else %>

<% location = "custom.asp?"& strCompanyLoginName & "&lc=en" %>

&nbsp;&nbsp;<input type="button" value="Anglais"  onClick="document.location='<%=location%>'">
 
<% end if %>

</form>
0
 
Manuel Marienne-DuchêneITMCommented:
0
 
KnowledgeWareAuthor Commented:
Figured it out, it works, no mixup of technologies
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.