Avatar of pothireddysunil
pothireddysunil

asked on 

How to get an html anchor tag href value when clicking that href link

I have a classic asp page with 5 anchor tags. When clicking any one of the tag, i want to get the value of that href tag (or  the DocType value) and want to store that in a session.

<%
var strSearchUrl = getFilePath( "CustomSearchdsp.asp")
%>
            <TABLE id = customize margin-left = 49px; margin-right:49px;>
            <TR>
                  <TD><A HREF  = "<%=strSearchUrl%>?DocType=Ordinance"> Ordinance </A></TD>
            </TR>
            <TR>
                  <TD><A HREF   = "<%=strSearchUrl%>?DocType=Resolution"> Resolution </A></TD>
            </TR>
            <TR>
                  <TD><A HREF  = "<%=strSearchUrl%>?DocType=Agenda"> Agenda </A></TD>
            </TR>
            <TR>
                  <TD><A HREF  = "<%=strSearchUrl%>?DocType=Minutes"> Minutes </A></TD>
            </TR>
            <TR>
                  <TD><A HREF  =  "<%=strSearchUrl%>?DocType=Permits"> Permits   </A></TD>
            </TR>
            </TABLE>
ASPMicrosoft DevelopmentWeb Applications

Avatar of undefined
Last Comment
Big Monty
Avatar of Big Monty
Big Monty
Flag of United States of America image

use Request.QueryString on CustomSearchdsp.asp:

Session("docType") = Request.QueryString("docType")

Open in new window

SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of pothireddysunil
pothireddysunil

ASKER

Hi Monty, I tried both and they are not working. so, i am thinking of some script to get the clicked anchor href value and text value. Is there any way to do this.
Avatar of Big Monty
Big Monty
Flag of United States of America image

I tried both and they are not working

this is pretty vague...WHAT'S not working? error? not the desired results?

maybe if you post your code, I can spot where you went wrong
Avatar of pothireddysunil

ASKER

This is my whole asp page and i am getting the value for Request.QueryString("DocType") as undefined

<%            
      expirePage();
      Response.Buffer=true;

      var uid = "DMUser";
      Session("user") = uid;
      var pwd = "password";
      var lib = "DOCSLIB_TEST";
      var alias = "";
      var IWAloginedUser = uid;
      var mustLogin = "N";
      var forceLogin = "N";
      Server.ScriptTimeout = 1200;

      var sysParms = new SystemParameters();
      var bis = sysParms.getBuiltInSymbols();


          bis.AllowAutoLogin  = 1;
      if(1 == bis.AllowAutoLogin)
      loginToLibrary( uid, pwd, lib, alias )

      setSearchLibraries();

      Session("Start") = "";

      if(Session("Start") == "")
      {
      strDocType = "" + Request.QueryString("DocType");

      Response.write(" this is a test " + strDocType);

       Response.write("sesson value 1" + Session("Start"));
           Session("Start") = 0;
      }
      else
      {
       Response.write("sesson value 2" + Session("Start"));
           Session("Start") = 0;
      }

      Session("noframes") = "YES";

      var strSearchUrl = getFilePath( "CustomSearchdsp.asp");
%>
<html>
<TABLE id = customize margin-left = 49px; margin-right:49px;>
      <TR>
            <TD><A HREF  = "<%=strSearchUrl%>?DocType=Ordinance"> Ordinance </A></TD>
      </TR>
      <TR>
            <TD><A HREF   = "<%=strSearchUrl%>?DocType=Resolution"> Resolution </A></TD>
      </TR>
      <TR>
            <TD><A HREF  = "<%=strSearchUrl%>?DocType=Agenda"> Agenda </A></TD>
      </TR>
      <TR>
            <TD><A HREF  = "<%=strSearchUrl%>?DocType=Minutes"> Minutes </A></TD>
      </TR>
      <TR>
            <TD><A HREF  =  "<%=strSearchUrl%>?DocType=Permits"> Permits   </A></TD>
      </TR>
</TABLE>
</html>
Avatar of Big Monty
Big Monty
Flag of United States of America image

upon initial page load, yes, it'll be undefined. it will only populate once you click one of the links.

and just to clarify, this IS classic asp, and not asp.net, correct?
Avatar of pothireddysunil
pothireddysunil

ASKER

Yes Monty. it's classic asp
Avatar of Big Monty
Big Monty
Flag of United States of America image

and when you click the link, it still comes up as undefined?
Avatar of Gary
Gary
Flag of Ireland image

You are mixing ASP and Javascript/C# etc code - nothing to do with classic ASP

Things like this are the javascript/C# and other languages' way of writing code
      if(Session("Start") == "")
       {

    var strSearchUrl
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of pothireddysunil
pothireddysunil

ASKER

thanks
Avatar of Big Monty
Big Monty
Flag of United States of America image

just curious, why the grade of B? what more were you looking for in an answer?
ASP
ASP

Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.

82K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo