473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Simple Asp Code To Print Name?

Hello,

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
7 2191
Okay i realised how to do it, but not in the most stylish way....

<SCRIPT LANGUAGE="VBScript">
<!--
Sub MyFunctionA()
Dim Letter
Letter = "You selected A"
txtResult.Value = Letter
End Sub
-->
</SCRIPT>

goes at the top, and my code is

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


and is displayed:

<Table>
<tr>
<td>Name:</td>
<td><input type="text" name="txtResult"size="40"></td>
</tr>
</Table>


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
Nicodemas
164 Expert 100+
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. %>
  5.  
  6. <a href="?n=A">A</a>
  7.  
  8. <%
  9. if myName <> "" then
  10.    response.write "I clicked: "& myName
  11. end if
  12. %>
  13.  
Does this answer your question?
Dec 6 '07 #3
i since hanged my code, to use javascript and post data,... but now in trying to read post data from my hyperlink...


<SCRIPT LANGUAGE="JavaScript">
<!--
function AddWithForm()
{
//Variables will be retrieved from submitted form
document.Shows.submit();
return true;
}
-->
</SCRIPT>

-------------------------------------------------------

<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
deric
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
Nicodemas
164 Expert 100+
Did you try my code above? It should work just fine.
Dec 11 '07 #6
IN ASP

Place a LinkButton
on doubleclick
Response.Write("Name");
Dec 11 '07 #7
Nicodemas
164 Expert 100+
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

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

Similar topics

2
by: Cergon | last post by:
hi, i hope someone can help. Im pretty new to this php stuff and i have a slight problem. I have this script (shown below) which writes data to a text file which is then displayed on my front...
10
by: george young | last post by:
For each run of my app, I have a known set of (<100) wafer names. Names are sometimes simply integers, sometimes a short string, and sometimes a short string followed by an integer, e.g.: 5, 6,...
7
by: mx2k | last post by:
Hello @ all, we have written a small program (code below) for our own in-developement rpg system, which is getting values for 4 RPG-Characters and doing some calculations with it. now we're...
27
by: Brian Sabbey | last post by:
Here is a first draft of a PEP for thunks. Please let me know what you think. If there is a positive response, I will create a real PEP. I made a patch that implements thunks as described here....
3
by: Dara Durum | last post by:
Hi ! Py2.4, Win32. I need to optimize a program that have a speciality: hash (MD5/SHA1) the file contents (many files). Now I do this in a simple python program, because (what a pity) the...
0
by: JohnLucas | last post by:
Hi all, I have just started working with the XML::Simple module to parse an XML file. I'm trying to pull some values from the file that I need in another program. The problem is that the XML...
6
by: SuperFool | last post by:
This has got to be one of those questions only a serious newbie would come up with.... Basicly: I select all the city names in the table and turn them into a pull down menu (code below) print...
5
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an...
8
by: autodidact | last post by:
I wrote a simple code to look up peoples numbers. But what if the user types in a name that is not on the list, how may i get my code to alert the user try again till a correct name is entered? ...
7
by: bvdp | last post by:
I'm finding my quest for a safe eval() quite frustrating :) Any comments on this: Just forget about getting python to do this and, instead, grab my set of values (from a user supplied text file)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.