Need java variable in an email form

K

Kelly

I have a java function that returns a value in the variable "name".
How can I get this value into a form field so that I can include it in
the emailed form results? I don't need it as an initial value in a
form field; I just need it included in the email that's sent back.

I have tried making a hidden form field with the name "test" and the
value "<%=name%>" but it's not getting passed.
 
J

jorabi1

I have a java function that returns a value in the variable "name".
How can I get this value into a form field so that I can include it in
the emailed form results?  I don't need it as an initial value in a
form field; I just need it included in the email that's sent back.

I have tried making a hidden form field with the name "test" and the
value "<%=name%>" but it's not getting passed.

forgot to mention, this is a plain html form, no asp files used.
 
T

Trevor Lawrence

I have a java function that returns a value in the variable "name".
How can I get this value into a form field so that I can include it in
the emailed form results? I don't need it as an initial value in a
form field; I just need it included in the email that's sent back.

I have tried making a hidden form field with the name "test" and the
value "<%=name%>" but it's not getting passed.
forgot to mention, this is a plain html form, no asp files used.

Do you mean javascript ?

If so, I will attempt to answer

First , it is not a good idea to name a variable "name", because "name" is a
keyword. So, try something else, let's say "fred".

Second, I think that the construct <%=name%> IS used in ASP which you are
NOT using

What you need to do is to execute code in javascript which loads the
variable into the form, but the variable name and value needs to be known at
the time.

Here is some sample code which loads the value when the " Send " button is
clicked.

You will probably want to do something else with the value rather than just
display it, but this demonstrates that it works.

<html>
<head>
<title>Form Test</title>
<script type="text/javascript">
var fred ="abcd123"; /* global variable */

function doit()
{document.form1.test.value=fred;}
</script>
</head>
<body>
<form name="form1">
<input type="text" id="test" />
<input type="button" value=" Send " onclick="doit()" />
</form>
</body>
</html>
 
J

jorabi1

Do you mean javascript ?

If so, I will attempt to answer

First , it is not a good idea to name a variable "name", because "name" is a
keyword. So, try something else, let's say "fred".

Second, I think that the construct <%=name%> IS used in ASP which you are
NOT using

What you need to do is to execute code in javascript which loads the
variable into the form, but the variable name and value needs to be knownat
the time.

Here is some sample code which loads the value when the " Send " button is
clicked.

You will probably want to do something else with the value rather than just
display it, but this demonstrates that it works.

<html>
<head>
  <title>Form Test</title>
  <script type="text/javascript">
  var fred ="abcd123";  /* global variable */

  function doit()
   {document.form1.test.value=fred;}
  </script>
</head>
<body>
     <form name="form1">
      <input type="text" id="test" />
      <input type="button" value=" Send " onclick="doit()" />
</form>
  </body>
</html>

Thanks but I am having trouble structuring it correctly because of
where the script is/isn't. Yes, I meant javascript. Here is a
portion of my page:

Note: getvalue function gets the value of 'fullname' out of the url
and works fine.

<html>

<head>

<title>Test Form</title>

<script type="text/javascript">
function getValue(varname)
//rest of the function is here
return value;
</script>

</head>

<form method="POST" name="Contact Us" action="--WEBBOT-SELF--"
onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit="return checkform(this);">

<!--webbot bot="SaveResults" S-Email-Format="TEXT/PRE" S-Email-
Address="(e-mail address removed)" B-Email-Label-Fields="TRUE" B-Email-
ReplyTo-From-Field="TRUE" S-Email-ReplyTo="replyemail" B-Email-Subject-
From-Field="FALSE" S-Email-Subject="Email Address Found" S-Builtin-
Fields startspan U-Confirmation-Url="confirmation.htm" -->
<!--webbot bot="SaveResults" endspan -->

// how do I get getvalue("fullname") into the above results?

YES! I know the email address for:
<p>
<script type="text/javascript">
var NeedName = getValue("fullname");
document.write(NeedName);
</script>
</p>

<p>
Here is their email address
<input name="MissingEmail" size="40"></p>
<p>Enter their email address again to confirm
<input name="EmailConfirm" size="40"></p>
<p>MY name is
<input name="SenderName" size="40"></p>
<p>MY email address is
<input name="replyemail" size="40"></p>
<p>
<input type="submit" value="Submit" name="submit"
</form>

</body>

</html>
 
T

Trevor Lawrence

Thanks but I am having trouble structuring it correctly because of
where the script is/isn't. Yes, I meant javascript. Here is a
portion of my page:
Note: getvalue function gets the value of 'fullname' out of the url
and works fine.
[snip of code]

I am confused.

You have this "comment" (It isn't an HTML comment as such - this would need
to be enclosed in said:
// how do I get getvalue("fullname") into the above results?

My question is where do you want to place getvalue("fullname") ?

Do you want it in "MissingEmail"?

I notice this code:
<form method="POST" name="Contact Us" action="--WEBBOT-SELF--"
onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit="return checkform(this);">

As far as I can tell (and I use http://www.w3schools.com/ as my reference)
this code does this when Submit is pressed:
First execute the javascript after onSubmit=
Then call the ASP file named after action= (which is NOT a file)
I have no idea what it does with webbot-onsubmit=

So what I oginally wrote was simpler code that inserts a value into the
form.

I have now enclosed some code adapted from yours. For testing, I needed a
value for the variable value, so I hard coded it to "(e-mail address removed)". The
next line places the value of value into the form. (Note that the variable
name "value" is not a good choice, but it does work.)

Because getValue() needs to be executed, I added onload ="getValue()" to the
body tag. Does it need to be executed somewhere else?

I understand that you don't want to send the contents of the form to an ASP
file, so I don't have an method="POST", but instead I have
<form name="form1" action="" onsubmit="doit()">

You will need to write the function named doit() to do what you want with
the contents of the form. If it is to send an email back to yourself, this
can be done, using the viewer's installed email client. I have written this
code in doit().

Am I on the right track for what you want ?

If not, please give me more info.

Code follows

<html>
<head>
<title>Test Form</title>
<script type="text/javascript">
function getValue(varname) {
/* rest of the function is here */
/* this line for testing only */
var value = "(e-mail address removed)";
document.form1.MissingEmail.value=value;
}
function doit() {
var subject = "Response from my page"
var body = "The sender's email was "
location.href='mailto:[email protected]'
+ '?subject=' + subject
+ '&body=' + body + document.form1.MissingEmail.value
}
</script>
</head>
<body onload="getValue()">
<form name="form1" action="" onsubmit="doit()">
<p>Here is their email address
<input name="MissingEmail" size="40"></p>
<p>Enter their email address again to confirm
<input name="EmailConfirm" size="40"></p>
<p>MY name is<input name="SenderName" size="40"></p>
<p>MY email address is<input name="replyemail" size="40"></p>
<p><input type="submit" value="Submit" name="submit"></p>
</form>
</body>
</html>
 
R

Ronx

When the page is published to a server running the extensions
<form method="POST" name="Contact Us" action="--WEBBOT-SELF--"
onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit="return checkform(this);">

will be changed to:

<form method="POST" name="Contact Us"
action="_vti_bin/shtml.dll/pagename.htm" onsubmit="return
checkform(this);" webbot-action="--WEBBOT-SELF--"> (Windows server)

Or to

<form method="POST" name="Contact Us"
action="_vti_bin/shtml.exe?pagename.htm" onsubmit="return
checkform(this);" webbot-action="--WEBBOT-SELF--"> (Unix server)

where pagename.htm is the name of the page the form is on.
--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.

http://www.rxs-enterprises.org/fp




Thanks but I am having trouble structuring it correctly because of
where the script is/isn't. Yes, I meant javascript. Here is a
portion of my page:
Note: getvalue function gets the value of 'fullname' out of the url
and works fine.
[snip of code]

I am confused.

You have this "comment" (It isn't an HTML comment as such - this would need
to be enclosed in said:
// how do I get getvalue("fullname") into the above results?

My question is where do you want to place getvalue("fullname") ?

Do you want it in "MissingEmail"?

I notice this code:
<form method="POST" name="Contact Us" action="--WEBBOT-SELF--"
onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit="return checkform(this);">

As far as I can tell (and I use http://www.w3schools.com/ as my reference)
this code does this when Submit is pressed:
First execute the javascript after onSubmit=
Then call the ASP file named after action= (which is NOT a file)
I have no idea what it does with webbot-onsubmit=

So what I oginally wrote was simpler code that inserts a value into the
form.

I have now enclosed some code adapted from yours. For testing, I needed a
value for the variable value, so I hard coded it to "(e-mail address removed)". The
next line places the value of value into the form. (Note that the variable
name "value" is not a good choice, but it does work.)

Because getValue() needs to be executed, I added onload ="getValue()" to the
body tag. Does it need to be executed somewhere else?

I understand that you don't want to send the contents of the form to an ASP
file, so I don't have an method="POST", but instead I have
<form name="form1" action="" onsubmit="doit()">

You will need to write the function named doit() to do what you want with
the contents of the form. If it is to send an email back to yourself, this
can be done, using the viewer's installed email client. I have written this
code in doit().

Am I on the right track for what you want ?

If not, please give me more info.

Code follows

<html>
<head>
<title>Test Form</title>
<script type="text/javascript">
function getValue(varname) {
/* rest of the function is here */
/* this line for testing only */
var value = "(e-mail address removed)";
document.form1.MissingEmail.value=value;
}
function doit() {
var subject = "Response from my page"
var body = "The sender's email was "
location.href='mailto:[email protected]'
+ '?subject=' + subject
+ '&body=' + body + document.form1.MissingEmail.value
}
</script>
</head>
<body onload="getValue()">
<form name="form1" action="" onsubmit="doit()">
<p>Here is their email address
<input name="MissingEmail" size="40"></p>
<p>Enter their email address again to confirm
<input name="EmailConfirm" size="40"></p>
<p>MY name is<input name="SenderName" size="40"></p>
<p>MY email address is<input name="replyemail" size="40"></p>
<p><input type="submit" value="Submit" name="submit"></p>
</form>
</body>
</html>
 
J

jorabi1

Thanks but I am having trouble structuring it correctly because of
where the script is/isn't.  Yes, I meant javascript.  Here is a
portion of my page:
Note: getvalue function gets the value of 'fullname' out of the url
and works fine.
[snip of code]

I am confused.

You have this "comment" (It isn't an HTML comment as such - this would need
to be enclosed in said:
// how do I get getvalue("fullname") into the above results?

I thought they both worked, but yes, I meant it to be a comment to
you.
My question is where do you want to place getvalue("fullname") ?

Do you want it in "MissingEmail"?

No, MissingEmail is for something else ... it's manually inputted by
the user. The form is basically a way for users to send me the email
address ('MissingEmail') of a person whose fullname is in the url of
this page with the form. Like www.mydomain.com/testform.htm?fullname=Joe
I notice this code:
<form method="POST" name="Contact Us" action="--WEBBOT-SELF--"
onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit="return checkform(this);">

As far as I can tell (and I usehttp://www.w3schools.com/as my reference)
this code does this when Submit is pressed:
First execute the javascript after onSubmit=
Then call the ASP file named after action= (which is NOT a file)
I have no idea what it does with webbot-onsubmit=

That is what Frontpage inserts. Ronx's reply says what happens when
it is published to the server (thanks Ronx).
So what I oginally wrote was simpler code that inserts a value into the
form.

I have now enclosed some code adapted from yours. For testing, I needed a
value for the variable value, so I hard coded it to "(e-mail address removed)". The
next line places the value of value into the form. (Note that the variable
name "value" is not a good choice, but it does work.)

Because getValue() needs to be executed, I added onload ="getValue()" to the
body tag. Does it need to be executed somewhere else?

I understand that you don't want to send the contents of the form to an ASP
file, so I don't have an method="POST", but instead I have
<form name="form1" action="" onsubmit="doit()">

You will need to write the function named doit() to do what you want with
the contents of the form. If it is to send an email back to yourself, this
can be done, using the viewer's installed email client. I have written this
code in doit().

Am I on the right track for what you want ?

If not, please give me more info.

Actually the server has to send the email, not the client. It uses
the Frontpage extensions to do this.

I have all of it working EXCEPT I need the value of 'fullname' from
the url to be added to the top of the email that gets sent back.
Right now, the email I receive contains this:

MissingEmail: (e-mail address removed)
SenderName: Carol
replyemail: (e-mail address removed)

But I want the email I receive to contain this:

Fullname: Joe
MissingEmail: (e-mail address removed)
SenderName: Carol
replyemail: (e-mail address removed)

I already have a function in javascript that returns the parsed
'fullname' from the url. It is called getvalue("fullname"). I just
don't know how to get that value into the form results.

MissingEmail, SenderName, replyemail are all fields that the user
fills in. As I said, fullname is NOT a field they fill in, it's the
result of the function.
Code follows

<html>
<head>
<title>Test Form</title>
<script type="text/javascript">
function getValue(varname) {
/* rest of the function is here */
/* this line for testing only */
var value = "(e-mail address removed)";
document.form1.MissingEmail.value=value;}

function doit() {
var subject = "Response from my page"
var body = "The sender's email was "
location.href='mailto:[email protected]'
     + '?subject=' + subject
     + '&body=' + body + document.form1.MissingEmail.value}

</script>
</head>
<body onload="getValue()">
<form name="form1" action="" onsubmit="doit()">
<p>Here is their email address
<input name="MissingEmail" size="40"></p>
<p>Enter their email address again to confirm
<input name="EmailConfirm" size="40"></p>
<p>MY name is<input name="SenderName" size="40"></p>
<p>MY email address is<input name="replyemail" size="40"></p>
<p><input type="submit" value="Submit" name="submit"></p>
</form>
</body>
</html>

Thanks for your time!
 
T

Trevor Lawrence

Replies in-line
No, MissingEmail is for something else ... it's manually inputted by
the user. The form is basically a way for users to send me the email
address ('MissingEmail') of a person whose fullname is in the url of
this page with the form. Like www.mydomain.com/testform.htm?fullname=Joe


That is what Frontpage inserts. Ronx's reply says what happens when
it is published to the server (thanks Ronx).

Yes, thanks Ron
I thought that the OP may have been using FPSE to send the EMail

I haven't done this, but I'll work from what I know to try to answer the
questions
I have all of it working EXCEPT I need the value of 'fullname' from
the url to be added to the top of the email that gets sent back.
Right now, the email I receive contains this:

MissingEmail: (e-mail address removed)
SenderName: Carol
replyemail: (e-mail address removed)

But I want the email I receive to contain this:

Fullname: Joe
MissingEmail: (e-mail address removed)
SenderName: Carol
replyemail: (e-mail address removed)

I already have a function in javascript that returns the parsed
'fullname' from the url. It is called getvalue("fullname"). I just
don't know how to get that value into the form results.

MissingEmail, SenderName, replyemail are all fields that the user
fills in. As I said, fullname is NOT a field they fill in, it's the
result of the function.

OK. I see now.

Since the fields that ARE being picked up by the server are all in the form,
I assume that all that you need to do is to pick up another field from the
form and that you are able to do that quite OK

So the real question is
How do I get the field into the form?.

I have tried again .
For testing, I added onload="getValue()" to the body tag.
In getValue(), I hard coded the value of the variable "returnvalue" to
"Joe".
Note that the function does not *return* this value but instead writes it
into the hidden field "resultname" in the form.

There may be a problem here in that you want to pass "fullname" to the
function and I don't know where this comes from.

Since it looks like I may still be a little off track, it would help to have
a reference to the code as it is (even if not working 100%) including the
function getValue()

Code follows
<html>

<head>
<title>Test Form</title>
<script type="text/javascript">
function getValue(varname){
/* rest of the function is here */

/* this line for testing only */
var returnvalue = "Joe";
document.form1.resultname.value=returnvalue;
}
</script>

</head>

<body onload="getValue()">

<form method="POST" name="form1" action="--WEBBOT-SELF--"
onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit="return checkform(this);">

<p>
Here is their email address
<input name="MissingEmail" size="40"></p>

<p>Enter their email address again to confirm
<input name="EmailConfirm" size="40"></p>

<p>MY name is
<input name="SenderName" size="40"></p>

<p>MY email address is
<input name="replyemail" size="40"></p>

<p><input type="hidden" name="resultname" size="40"></p>

<p>
<input type="submit" value="Submit" name="submit">
</p>
</form>

</body>
</html>
 

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

Top