• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 454
  • Last Modified:

How to add variable to an HREF in ASP using vbscript

I'm trying to do the following:

<% TestStatement = "This Variable works" %>
<a href="Page.asp">TestStatement</a> 

Open in new window


So the page would read "This Variable works" as a hyperlink and would direct the user to page.asp.

0
Darkejo1
Asked:
Darkejo1
  • 4
  • 3
1 Solution
 
Chris BottomleyCommented:
Ought to work ... is javascript the language at that point ... a quick test with:


<%SCRIPT=JAVASCRIPT TestStatement = "This Variable works" %>
<a href="Page.asp">TestStatement</a><div id="masthead">

in an html page forwards as required.

Chris
0
 
Darkejo1Author Commented:
I'm not familiar with JavaScript as I'm using VBScript. When I add suggestion, I receive Expected end of statement:

Script=JAVASCRIP TestStatement = "This Variable works"

Open in new window


At the letter "T" in Test.
0
 
Darkejo1Author Commented:
I was able to get rid of that error message. This is what I have so far.

<%Language=JAVASCRIPT%>
<%Teststatement="This Variable Works"%>
<a href="Page.asp">TestStatement</a><div id="masthead">

Open in new window


The Result is "TestStatment" as a hyperlink. Instead, it should say "This Variabel Works" as they hyperlink.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Chris BottomleyCommented:
I realised after my post I was in error ... and am currently making silly mistakes in extremis.

I will try to clear the fog from my mind or see someone else help you before I succeed.

Chris
0
 
Chris BottomleyCommented:
Try:


TestStatement = "This Variable works"
document.write("<a href=""Page.asp"">" & TestStatement & "</a>")


Chris
0
 
Darkejo1Author Commented:
Worked like a charm! Thanks!!
0
 
Chris BottomleyCommented:
And i'm sorry for not understanding earlier what was required ... but glad you have a solution.

Chris
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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