[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3114
  • Last Modified:

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>
0
KnowledgeWare
Asked:
KnowledgeWare
  • 2
1 Solution
 
Manuel Marienne-DuchêneITMCommented:
0
 
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
 
KnowledgeWareAuthor Commented:
Figured it out, it works, no mixup of technologies
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now