Pass the value of a input box through a hyperlink

M

Martix

Hello

I would like to pass the value of a inputbox through a hyperlink. I
know this can be done with a single valuelike:

<a href="employee.asp?e_num=6">Market Info </a>

My problem is that I need the "6" to be a variable pending on what's
in the input box.

How do I do that?
 
B

BootNic

Martix said:
news: (e-mail address removed)
Hello

I would like to pass the value of a inputbox through a hyperlink. I
know this can be done with a single valuelike:

<a href="employee.asp?e_num=6">Market Info </a>

My problem is that I need the "6" to be a variable pending on what's
in the input box.

How do I do that?

Use a form, that's what it does.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<form action="employee.asp">
<div>
<input name="e_num">
<br>
<input style="border:none; background-color:#fff; color:#00F;
cursor:pointer;" type="submit" value="Market Info">
</div>
</form>
</body>
</html>

--
BootNic Monday, March 26, 2007 3:39 PM

"Do not trust your memory; it is a net full of holes; the most
beautiful prizes slip through it."
*Georges Duhamel, The Heart's Domain*
 
M

Martix

Use a form, that's what it does.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<form action="employee.asp">
<div>
<input name="e_num">
<br>
<input style="border:none; background-color:#fff; color:#00F;
cursor:pointer;" type="submit" value="Market Info">
</div>
</form>
</body>
</html>

--
BootNic Monday, March 26, 2007 3:39 PM

"Do not trust your memory; it is a net full of holes; the most
beautiful prizes slip through it."
*Georges Duhamel, The Heart's Domain*

What would I do if I had more then one hyperlink pulling the value
from the same inputbox??
 
B

BootNic

Martix said:
news: (e-mail address removed)
[snip]

What would I do if I had more then one hyperlink pulling the value
from the same inputbox??

Provide a better example of what you are trying to achive. At the
moment I can't see why you would want to spread the same action all
over a page.

If you only have one input, why would you need more then
one place to submit the info?

At any rate, if you wish to depend on Javascript .

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<form action="employee.asp">
<div>
<input id="bob" name="e_num">
</div>
</form>
<a href="JavascriptRequired.asp" onclick="this.href='employee.asp?'+
document.getElementById('bob').value;return true;">
Market Info
</a>
</body>
</html>

--
BootNic Monday, March 26, 2007 4:56 PM

"My God! The thought of that evil man, loose in London--with money,
from God only knows what source--fomenting riot and rebellion during
a public emergency--and in control of an Engine-driven press! It's
nightmarish!"
*Gibson-Sterling*
 
M

Martix

1174941029.981506.277__BEGIN_MASK_n#9g02mG7!__...__END_MASK_i?a63jfAD$z__@l75g2000hse.googlegroups.com
1174936716.054843.57...__END_MASK_i?a63jfAD$__BEGIN_MASK_n#[email protected]
Hello
I would like to pass the value of a inputbox through a hyperlink. I
know this can be done with a single valuelike:
<a href="employee.asp?e_num=6">Market Info </a>
[snip]

What would I do if I had more then one hyperlink pulling the value
from the same inputbox??

Provide a better example of what you are trying to achive. At the
moment I can't see why you would want to spread the same action all
over a page.

If you only have one input, why would you need more then
one place to submit the info?

At any rate, if you wish to depend on Javascript .

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<form action="employee.asp">
<div>
<input id="bob" name="e_num">
</div>
</form>
<a href="JavascriptRequired.asp" onclick="this.href='employee.asp?'+
document.getElementById('bob').value;return true;">
Market Info
</a>
</body>
</html>

--
BootNic Monday, March 26, 2007 4:56 PM

"My God! The thought of that evil man, loose in London--with money,
from God only knows what source--fomenting riot and rebellion during
a public emergency--and in control of an Engine-driven press! It's
nightmarish!"
*Gibson-Sterling*- Hide quoted text -

- Show quoted text -

As an example:

You input an employee id and his name comes up in the top frame. In
the same frame there's a row of hyperlinks. Contact info, employment
history, Qualifications, etc

When the links are clicked a new window comes up in the bottom frame.
The employee ID would need to be passed for each of the links in order
for the asp page to be able to bring up the right information.

If there's a better way of doing it. Please let me know
 
J

Jonathan N. Little

Martix said:
What would I do if I had more then one hyperlink pulling the value
from the same inputbox??

Make it easy on you with tree little words: *use a form*
 
M

Martix

Make it easy on you with tree little words: *use a form*

how can the different hyperlink pull the same value from the same
form?? If there was only one link then I wouldn't have a problem.
 
B

BootNic

Martix said:
news: (e-mail address removed)
I would like to pass the value of a inputbox through a hyperlink.
I know this can be done with a single valuelike:
<a href="employee.asp?e_num=6">Market Info </a> [snip]

What would I do if I had more then one hyperlink pulling the value
from the same inputbox??

Provide a better example of what you are trying to achive. At the
moment I can't see why you would want to spread the same action all
over a page.

If you only have one input, why would you need more then
one place to submit the info?
[snip]

As an example:

You input an employee id and his name comes up in the top frame. In
the same frame there's a row of hyperlinks. Contact info, employment
history, Qualifications, etc

When the links are clicked a new window comes up in the bottom frame.
The employee ID would need to be passed for each of the links in order
for the asp page to be able to bring up the right information.

If there's a better way of doing it. Please let me know

Use a form, create the page on the server, you may even be able to
do away with the frames.

However, as I do not like to play with asp, you will need to seek help
with that from another group or perhaps someone here that likes to
play with asp.
 
J

Jonathan N. Little

how can the different hyperlink pull the same value from the same
form?? If there was only one link then I wouldn't have a problem.

No Hyperlinks

<form action="getstuff.asp" method="post">
<div>
<label for="e_num">Employee No:
<input name="e_num" id="e_num" type="text">

<label for="r_id">
<select name="r_id" id="r_id">
<option value="1">Contact info</option>
<option value="2">Qualifications</option>
....
<option value="n">Employment History</option>
<input type="submit" value="Go Fetch!">
</select>

</div>
</form>

Then have "getstuff.asp"
[pseudocode]

Switch "r_id"

case is 1: query dB for "e_num" contact info
case is 2: query dB for "e_num" qualifications info

....
 
B

Brian Cryer

Martix said:
Hello

I would like to pass the value of a inputbox through a hyperlink. I
know this can be done with a single valuelike:

<a href="employee.asp?e_num=6">Market Info </a>

My problem is that I need the "6" to be a variable pending on what's
in the input box.

How do I do that?

Whilst it doesn't directly answer your question, you may find the following
helps: http://www.cryer.co.uk/resources/javascript/script8.htm - Article on
passing data from one page to another. Has an emphasis on JavaScript, but
demonstrates how to pass data via a url.
 
J

Jukka K. Korpela

Scripsit Martix:

[massive quotation deleted here - consider using a newsreader instead of
"Google Groups" for posting, or learn to use "Google Groups"]
You input an employee id and his name comes up in the top frame.

As usual, a URL would say more than a thousand words, though in this case,
constructing a demo page might take quite some work (if this is really an
intranet application and cannot be disclosed to the public).
In the same frame there's a row of hyperlinks. Contact info, employment
history, Qualifications, etc

You can use links there, or you could make them submit buttons. The latter
might be technically easier.
The employee ID would need to be passed for each of the links in order
for the asp page to be able to bring up the right information.

Then you can encode the employee ID into the URLs for the links; something
like

employee.asp?e_num=6&ID=42

The code that handles clicking on an employer name needs to retrieve the ID
anyway, and then it should include it into the code that it generates.

(Note: In HTML, the "&" needs to be encoded as "&amp;".)
 
M

Martix

I want to use links.

What's the syntaxt I would use.

<form name= "inputs" method=post>
<p align="center">Input Phone Number <input type="text" name="Tin"
size="20"> Employee Name
<input type="text" name="Tname" size="20"> Employee Number
<input type="text" name="Tcc" size="20" value="6"></p>
<p align="center">
</form>

<a href="emp_info.asp">Employee Info </a>
<a href="skills.asp">Skills</a>
<a href="history.asp">Employee History</a>
<a href="references.asp">References</a>

These are some examples. How would I code it so that when I click each
link it gets the Employee number from the form and passes it through
the link?
 
J

Jukka K. Korpela

Scripsit Martix:
I want to use links.

Are you commenting on something? Then you should quote or paraphrase the key
sentence or two.

I think you missed some of the answers already posted, and the odds are that
you'll fail to understand any further advice. If this guess is wrong, you
can always reread the answers and post a meaningful comment that indicates
that you understood them.
 
M

Martix

Jonathan N. Little stated I could use a drop down list box. But I
really don't want to do it that way. I really want to use links.
You can use links there, or you could make them submit buttons. The latter
might be technically easier.

How do I use the links? How do you place the a variable in the code?
Then you can encode the employee ID into the URLs for the links; something
like


The code that handles clicking on an employer name needs to retrieve the ID
anyway, and then it should include it into the code that it generates.

As in the example I just displayed. I just need the the employee
number to get passed through.
(Note: In HTML, the "&" needs to be encoded as "&amp;".)

How do I use this information?

<a href="emp_info.asp?e_num=" &amp document.inputs.Tcc.value>Employee
Info </a>
 
J

Jonathan N. Little

Martix said:
Jonathan N. Little stated I could use a drop down list box. But I
really don't want to do it that way. I really want to use links.

But *that* is what form are for* *Submitting* information. Links are for
*linking* to other pages.
How do I use the links? How do you place the a variable in the code?


As in the example I just displayed. I just need the the employee
number to get passed through.


How do I use this information?

<a href="emp_info.asp?e_num=" &amp document.inputs.Tcc.value>Employee
Info </a>

You cannot do this without depending on JavaScript...bad idea! Or using
a login procedure that create a session where the employee id is stored
and your pages could not be static html, but some version of
server-side, like your emp_info.asp. "emp_info.asp" would no get the
e_num form the query string but from the value stored in the session...

But would you not say that it is easier to eat soup with a spoon and not
a fork? There is a mechanism for submitting data...it is called a form.
 
M

Martix

But *that* is what form are for* *Submitting* information. Links are for
*linking* to other pages.












You cannot do this without depending on JavaScript...bad idea! Or using
a login procedure that create a session where the employee id is stored
and your pages could not be static html, but some version of
server-side, like your emp_info.asp. "emp_info.asp" would no get the
e_num form the query string but from the value stored in the session...

But would you not say that it is easier to eat soup with a spoon and not
a fork? There is a mechanism for submitting data...it is called a form.

So even if I had a row of buttons instead of link. How would I code it
so that each button links it to a different page? I don't want to use
a list box
 
J

Jonathan N. Little

Martix wrote:
So even if I had a row of buttons instead of link. How would I code it
so that each button links it to a different page? I don't want to use
a list box
You don't as I demonstrated earlier in the thread. You post to an
intermediate handler script that depending on which submit button is
click will serve up related info...

You could do it either by putting a select box for the resource you wish
to retrieve:

"getstuff.asp" method="post">
<div>
<label for="e_num">Employee No:
<input name="e_num" id="e_num" type="text">

<label for="r_id">
<select name="r_id" id="r_id">
<option value="1">Contact info</option>
<option value="2">Qualifications</option>
....
<option value="n">Employment History</option>
<input type="submit" value="Go Fetch!">
</select>

</div>
</form>

Then have "getstuff.asp"
[pseudocode]

Switch "r_id"

case is 1: query dB for "e_num" contact info
case is 2: query dB for "e_num" qualifications info


OR you can have different named submit buttons:

"getstuff.asp" method="post">
<div>
<label for="e_num">Employee No:
<input name="e_num" id="e_num" type="text">
</div>
<div>
<input type="submit" name="contact" value="Contact Info">
<input type="submit" name="qualifications" value="Qualifications">
<input type="submit" name="history" value="History">
....
</div>
<form>

Then have "getstuff.asp"
[pseudocode]

If POST var "contact" exists {
query dB for "e_num" contact info
}
else if POST var "qualifications" exists {
query dB for "e_num" qualifications info
}
else if POST var "history" exists {
query dB for "e_num" history info
}

and so on...

The query can also be a redirect...
 
A

Adrienne Boswell

Hello

I would like to pass the value of a inputbox through a hyperlink. I
know this can be done with a single valuelike:

<a href="employee.asp?e_num=6">Market Info </a>

My problem is that I need the "6" to be a variable pending on what's
in the input box.

How do I do that?

Quick and dirty:
<% option explicit
dim employee, goodtogo, rs, rsarr, sql
dim ix, field, inputvalue, thestring

if Request.ServerVariables("REQUEST_METHOD") = "POST" then
For ix = 1 to Request.Form.Count
field = request.form.key(ix)
inputvalue = request.form.item(ix)
TheString = field & "= Request.Form(""" & field & """)"
Execute(TheString)
next

sql "SELECT id, name FROM table WHERE field = " & employee
rs.open sql, connectionstring
if rs.open then
rsarr = rs.getrows()
recordsfound = true
else
recordsfound = false
end if
rs.Close
set rs = nothing
goodtogo = true
else
goodtogo = false
end if
%>
<% if not goodtogo then %>

<form method="post" action="<%=request.servervariables("HTTP_REFERER")%>">
<div>
<label for="employee" id="employee1">Employee: </label>
<input type="text" name="employee" id="employee" value="<%=employee%>">
<input type="submit" value="Submit">
</div>
</form>

<% else%>

<ul>
<% for i = 0 to ubound(rsarr)%>
<li><a href="page.asp?id=<%=rsarr(0,i)%><%=rsarr(1,i)%></li>
<% next%>
</ul>

<% end if%>
 
M

Martix

I really liked what Jonathan wrote
If POST var "contact" exists {
query dB for "e_num" contact info
}
else if POST var "qualifications" exists {
query dB for "e_num" qualifications info
}
else if POST var "history" exists {
query dB for "e_num" history info
}

I understand that it's pseudocode. Does anyone know what that actually
asp code would be??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top