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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form and registration

Status
Not open for further replies.

dmccallum

Programmer
Jan 5, 2001
90
US
I have a page that accepts and installation number, performs some math when the user hits the button, and give them a serial number. I would like to be able to also ask for their name, company name, e-mail address, etc. and when the button is hit to perform the math the personal data would be e-mailed to me. I tried adding the action on the same line as the math but that just causes my serial number to flash on the screen, nothing is e-mailed. What am I doing wrong?
 
I haven't been able to send the form's information to my e-mail address yet. I have action do a calculation and output on the same screen but I would like for the action to e-mail me the results when someone fills out the form and then go to another page that displays the results of the calculation.
 
Try this....

Code:
<html>
<script language=&quot;JavaScript&quot;><!--
function update(what) {
     what.action = 'mailto:' + document.hiddenForm.emailAddress.value
                + '?SUBJECT=' + document.hiddenForm.subjectLine.value;
    setTimeout('self.location=&quot;[URL unfurl="true"]http://www.msn.com&quot;',10000);[/URL]
}
//--></script>

<form name=&quot;hiddenForm&quot; onSubmit=&quot;return false&quot;>
<input type=&quot;hidden&quot; name=&quot;emailAddress&quot; value=&quot;you@somewhere.com&quot;>
<input type=&quot;hidden&quot; name=&quot;subjectLine&quot; value=&quot;Registration&quot;>
</form>

<form name=&quot;emailForm&quot; method=&quot;post&quot; enctype=&quot;text/plain&quot; >
Name: <input type=&quot;text&quot; name=&quot;custname&quot;>
Email Address: <input type=&quot;text&quot; name=&quot;custemail&quot;>
<input type=&quot;submit&quot; value=&quot;get serial&quot; onClick=&quot;update(this.form)&quot;>
</form>
</html>
 
That's almost it. I modified it to add this line:

Installation Number: <input type=&quot;numeric&quot; name=&quot;installnum&quot;>

But originally I had:

<form name=form1>
<p>Enter the Installation Number below. When you hit submit you will receive
a Serial Number. This number is needed to continue your software installation.</p>
<p>Installation Number:
<input type=text name=input value=&quot;&quot;>
Serial Number:
<input type=text name=output value=&quot;&quot;>
<br>
<input type=button value=&quot;submit&quot; onClick=&quot;form1.output.value=(form1.input.value*3)+15000&quot; name=&quot;button2&quot;>

</p></form>
</body>
</html>

So if someone entered the number 10 they received the number 15030. How can I insert this formula into the script you suggested and still have an email sent to me?

 
I added your formula to the update() function. If you are redirecting, you may want to display an alert box with the serial number, so the user has a chance to write it down. See code below:
Code:
<html>
<script language=&quot;JavaScript&quot;><!--
function update(what) {
     var serial = (document.emailForm.input.value*3)+15000;
     document.emailForm.output.value = serial
     alert('Your serial number is ' + serial + '.\nPlease make a note of it.');
     what.action = 'mailto:' + document.hiddenForm.emailAddress.value
                + '?SUBJECT=' + document.hiddenForm.subjectLine.value;
    setTimeout('self.location=&quot;[URL unfurl="true"]http://www.msn.com&quot;',10000);[/URL]
}
//--></script>

<form name=&quot;hiddenForm&quot; onSubmit=&quot;return false&quot;>
<input type=&quot;hidden&quot; name=&quot;emailAddress&quot; value=&quot;you@somewhere.com&quot;>
<input type=&quot;hidden&quot; name=&quot;subjectLine&quot; value=&quot;Registration&quot;>
</form>

<form name=&quot;emailForm&quot; method=&quot;post&quot; enctype=&quot;text/plain&quot; >
Name: <input type=&quot;text&quot; name=&quot;yourname&quot;>
Email Address: <input type=&quot;text&quot; name=&quot;youremail&quot;><br>
  <p>Enter the Installation Number below. When you hit submit you will receive
    a Serial Number. This number is needed to continue your software installation.</p>
  <p>Installation Number: <input type=text name=input value=&quot;&quot;>
  Serial Number: <input type=text name=output value=&quot;&quot;>
  <br>
</p>

<input type=&quot;submit&quot; value=&quot;submit&quot; onClick=&quot;update(this.form)&quot;>
</form>
</html>
 
It works great! Is there any way to prevent the Microsoft message box from popping up and asking if they want to send the e-mail or to cancel?
 
I don't think there's a way in JS or HTML. But if you were using ASP - you might be able to make a call to an .dll to send the email. Since it would be from the HTML form itself - you wouldn't get the message. But I'm not sure exactly how to do that.
 
If you used a server-side program to email you the data you wouldn't get that popup box either. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top