By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,913 Members | 1,464 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,913 IT Pros & Developers. It's quick & easy.

Simple Asp Code To Print Name?

P: 12

Im hoping you can help, for now im trying to learn how to do something so an easy example may help me to gain the concept.

I wish to create a hyperlink that when i click it, it prints my name further down the page.

I had a search for the last few hours on the <a Href> and onclick command, but this does not make sense?.. the part im getting confused is how am i able to call a function (something like response.write "boo") and get it able to print out on the same page... could some one please write a simple .asp page using vbscript so i can see how its done, then i can try to expand on that myself.

any help will be appriciated.

if i havent explained anything correct please feel free to ask, but its only a simple example i want... just so when i click a hyperlink, it prints some text out on the same page.

The reason i want this, is once i get the concept, i will have a list of the alphabet and on each one will have a sql statement that will return some values....

Im using .ASP, VBScript. thanks!
Dec 6 '07 #1
Share this Question
Share on Google+
7 Replies

P: 12
Okay i realised how to do it, but not in the most stylish way....

Sub MyFunctionA()
Dim Letter
Letter = "You selected A"
txtResult.Value = Letter
End Sub

goes at the top, and my code is

<A href="#" onClick="MyFunctionA()">a<a>

and is displayed:

<td><input type="text" name="txtResult"size="40"></td>

now just need to know how to pass something back via a variable so i can use response.write?... any ideas?
Dec 6 '07 #2

Expert 100+
P: 164
You could do somethign like this with JavaScript easily, but if you want ASP to do it, you could:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim myName
  3. myName = request.querystring("n")
  4. %>
  6. <a href="?n=A">A</a>
  8. <%
  9. if myName <> "" then
  10.    response.write "I clicked: "& myName
  11. end if
  12. %>
Does this answer your question?
Dec 6 '07 #3

P: 12
i since hanged my code, to use javascript and post data,... but now in trying to read post data from my hyperlink...

function AddWithForm()
//Variables will be retrieved from submitted form
return true;


<FORM id="Shows" name="Shows" method="post" action="Shows.asp">
'VB Scipt in here (server side)
dim Vletter
dim letter

letter = Request.Form("Number1")
Vletter = "The letter you have clicked on is: " & letter


<A href="#" id=Number1 name=Number1 value="a" onClick="AddWithForm()">a<a>


<% Response.Write Vletter %>

but this is not printing out the value thats been passed "a" just the text "The letter you have clicked on is: "....

any idea on how to solve this?....
Dec 7 '07 #4

P: 92
Maybe you didn't click the "a" link.. the form has to be submitted first before it can get the value of "Number1". On first load of the page, it doesn't have any form to request.
Dec 8 '07 #5

Expert 100+
P: 164
Did you try my code above? It should work just fine.
Dec 11 '07 #6

P: 8

Place a LinkButton
on doubleclick
Dec 11 '07 #7

Expert 100+
P: 164
Unless I completely misunderstood the original request, I have posted a viable solution to the user's problem. He isn't using .NET, as stated in the last sentence of the original topic.
Dec 13 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.