Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Variable Substitution

Status
Not open for further replies.

rfhall3

Programmer
Feb 7, 2003
28
US
I know this has been asked numerous times, but I can't find the answer.....

I am using MAILTO in HTML. I want to use a variable in my code, i.e., Input a field and include it in the message. Is this possible ???? I know there are better ways, but I would like to stick with this simple approach for now.

In the following code, I want to use the value inputted into T1 in place of the value [red]ZZZ[/red].

Simple sample code is:

[blue]
<html>
<head>
</head>
<body>
Name:
<input type="text" name="T1" size="34">
<p>
<A href='mailto:me@myisp.net?subject=MySub&body=AAA%0a[red]ZZZ[/red]%0aCCC'>Click to E-Mail</A>
</p>
</body>
</html>
[/blue]

Can it be done this way ????
Thank You Very Much.

Bob Hall
 
What language are you using to plug the variable value into the HTML code? It looks like you'd probably either use Javascript or VBScript.

Lee
 
There's nothing fancy here. It's all HTML. All I want to do is include whatever is typed in the input box to show up in the body of the e-mail.

Thanks.

Bobby

 
Just paste your report into the text area.

Code:
<html><head><title>
My Expense Report
</title></head>
<body bgcolor="yellow"><b>TO:
me@mysite.com
&nbsp;&nbsp;&nbsp;&nbsp;SUBJECT:
Expenses
</b><form method="POST"
action="mailto:
me@mysite.com
?subject=
Expenses
"enctype="text/plain" target=_blank>
<textarea name="Data" rows="20"
cols="80" readonly>
</textarea><br><br>
<input type="submit" value="Submit">
</form></body></html>

Clive
 
Sorry, I guess I was trying to keep the example toooooo simple. I actually have about 12 variables that I want to include in the e-mail. It's pretty much a questionaire. I just thought if I could get an example of one variable being included in the e-mail, I would just follow the same idea for the rest. But anyway, thank you for your reply.

Any other suggestions on using variables (and sticking with HTML) ?????

Thank You.

Bobby
 
>Any other suggestions on using variables (and sticking with HTML) ?????

Without using a script in the HTML code?

1. HTML alone will not do it.
2. Scripts are used in HTML to solve this type of problems.

The only way I know of:
3. From another application, you can create your HTML on the fly and thus include all the needed values. VB code can do this easily.

__________________________________________
Try forum1391 for lively discussions
 
I'll try to explain my problem better......

In the working example below there are 2 input boxes. In the real applicaion there are actually 12. The objective is to get the information typed in the input boxes to be included in the body of the email some how, some way.

This is about as simple as I can make it.

<html>
<head>
</head>
<body>
Name: <input type="text" name="T1" size="34">
<br>
Address: <input type="text" name="T2" size="34">
<br>
<A href='mailto:me@myisp.net?subject=MySub&body='>Click to E-Mail</A>
</body>
</html>

Any help is greatly appreciated.

Bobby
 
Have you tried adding the form action as the mailto:?

I have never used mailto for forms so not sure exactly how it works now but it should so what you are looking for.

Hope this helps

Wullie

Fresh Look - Quality Coldfusion/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
This code works for me:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html>
<head>
<title>Email form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<form action="mailto:me@mydomain.com?subject=Form results" method="post" enctype="text/plain">
Name: <input type="text" name="Name" /><br />
Age: <input type="text" name="Age" /><br />
<input type="submit" value="Send mail" />
</form>

</body>
</html>

This results in an email being sent to the specified address with the subject "Form results" and the following body:

Code:
Name=<name entered on form>
Age=<age entered on form>

Remember this relies on the user having a mail client installed and configured on their system.

--James
 
Thank y'all ever so much. The form method was exactly what I was looking for. Unfortunately, server side languages are not available with Cox, so ASP and PHP were not options.

Thanks again for the help.

[thumbsup2]
Bobby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top