codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  code for one submit button  Archive Import (Little E) at 13:03 on Monday, July 07, 2003
 

I`ve set up a forms webpage, but I need some code for my submit button. I`ve been told that it can be done in a couple of different ways for example: Java and CGI. I`m not a programmer so I don`t know which one is better or what the code would be for either of them. What I`ve had to do is setup my form link to a yahoo website because their software writes the code for me. I`ve tried using Dreamweaver, but it doesn`t write the code for my submit button (at least I can`t get it to). If you`d like to see the form I`m talking about it`s at http://www.geocities.com/fishindestin4ever/Reservations.html. Could you email me the code for the submit button?

Thank you,
Little E

  Re: code for one submit button  Archive Import (Big E) at 10:59 on Saturday, July 12, 2003
 

What are you trying to accomplish with the SUBMIT button?

  Re: code for one submit button  Archive Import (Little E) at 08:38 on Monday, July 14, 2003
 

What I want the submit button to do is send me the information that is in the form to my email address. Theres one form and one submit button.

  Re: code for one submit button  Troy Wolf at 12:35 on Tuesday, July 15, 2003
 

Well, you are going to need to learn SOME code to make this happen...or have enough things pre-configured on the server that it isn`t an issue. For example, if you take the code below and save it as "/forum/EmailForm.html", it will work as long as the server is configured to execute ASP, has CDONTS configured, and proper permissions are in place to use it. I stole (leveraged) this code, then stripped it down to try to keep it as no-frills as possible. It simply loops through whatever form you submit and generates an email body with name/value pairs.

If you are hosting with a professional hosting service that supports ASP, they probably already have an ASP Email component installed. One that is very popular is ASPemail. (http://www.aspemail.com/) If you have this component available on your server, then I can give you code examples for using it. The built in Windows method is to use CDONTS, but CDONTS has a bad reputation.

You have to edit the code below with your email address. Your form tag needs to be similar to this:

<form method=post action=EmailForm.asp>

ASP code below.
-----------------------------------
<%

`Initialize strBody string with the body of the e-mail
strBody = "Web Form Submission" & vbcrlf & _
"-----------------------------------------------" & vbcrlf
`Loop through the form elements creating a string with the names and values, one per line.
for each element in Request.Form
strBody = strBody & element & ": " & element.Value & vbcrlf
next

`Send the e-mail
`Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

`Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
objCDOMail.From = "you@yourdomain.com"

`Who the e-mail is sent to
objCDOMail.To = "you@yourdomain.com"

`Who the carbon copies are sent to
`objCDOMail.Cc = "someone_else@yourdomain.com"

`Set the subject of the e-mail
objCDOMail.Subject = "Webform Submission"

`Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

`Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

`Set the main body of the e-mail
objCDOMail.Body = strBody

`Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1

`Send the e-mail
objCDOMail.Send

`Close the server object
Set objCDOMail = Nothing
%>

<html>
<head>
<title>Webform Submission</title>
<body>
Thank you for submitting the form.
</body>
</html>
-----------------------------------
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: code for one submit button  Troy Wolf at 12:37 on Tuesday, July 15, 2003
 

By the way...the lines that begin with a single-tick are comments. This forum changes the single-ticks to the wrong one. When you copy & paste, you will have to replace those single ticks with "normal" single ticks. (What is normal anyway?!)
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: code for one submit button  MagicBus at 12:20 on Wednesday, September 10, 2003
 

I am using code that automatically fills the
To: cc: Subject: & Body of the user's e-mail when they click on Request Information.
Is there any way to include a "submit" that will keep the user from altering those fields?

  Re: code for one submit button  Troy Wolf at 14:11 on Wednesday, September 10, 2003
 

Why not just make those fields HIDDEN?
<input type=hidden name=TO value="troy@shinysolutions.com">


You do NOT want to DISABLE the fields because disabled elements do not pass a value back to the server.
<input type=text name=TO value="troy@shinysolutions.com" DISABLED>


Beyond this, you can script onFocus events in those fields to keep people from modifying the values, but just making those fields HIDDEN should be all you need.
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: Hiding email details  Troy Wolf at 14:20 on Thursday, September 11, 2003
 

MagicBus emailed to tell me that his code simply has an email link in his HTML that specifies a TO, CC, Subject, and Body. When users click the link, their email client opens a new email with this information automatically filled in. MagicBus wants to know if there is a way to prevent the user from modifying those fields in the email.

The answer is "no". All that link does is help them to start an email. You have no control over what they do with it from there.

If you want to have complete control over who the email is sent to and the subject line, etc., then you have to send the email yourself from your webserver. This will require that you provide a form to get at least an email address from your visitor--otherwise, how will you know who to contact?

The good thing about server-side email is that you have full control over the process. The bad thing is that some visitors will be cautious about entering their email address in a web page because of spam. (WHAT ARE WE GOING TO DO ABOUT SPAM! ARGH!)

So weigh your options. Sending server-side email will require some programming, but you can find lots of code examples on the net.

Here is some code that would help you to hide your email link details--in the web page. This does not solve your problem after the user has clicked the link and their new email is open. But people may find this code useful.
<script language=javascript>
function RequestInfo()
{
x = "mailto:bob@earthlink.net?"+
"subject=Reference Number 8721"+
"&cc=mary@earthlink.net"+
"&body=Please send detailed information on product #0002";
wname=window.open(x);
}
</script>
<body>
<a href="JavaScript:RequestInfo()"
onmouseover='window.status="Request Info"; return true;'
onmouseout='window.status=""'>
Request Info
</a>
</body>
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: code for one submit button  Elain at 07:20 on Tuesday, November 30, 2010
 

You can have more than one submit button in a form. But, how to identify from the server side which button submitted the form?

One way is to have different names for the submit buttons.

<input type="submit" name="Insert" value="Insert">
<input type="submit" name="Update" value="Update">

In the server side script you can do a check like this:
if(isset($Update))
{
//Do update here..
}
else
if(isset($Insert))
{
//Do insert Here
}
Note: The code depends on the server side scripting language you use. The code above is in PHP.

The second method is to have different values for submit buttons with the same name.

<input type="submit" name="Operation" value="Insert">
<input type="submit" name="Operation" value="Update">

and in the server side it could be handled like this:
if($Operation == "Update")
{
//Do update here..
}
else
if($Operation == "Insert")
{
//Do insert here
}
----------------------------------------------------------------------
flash banner|logo maker|flash menu|drop down menu|flash decompiler mac









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: How to Remove the URL`s from printouts
•  Re: 2 or more scripts
•  Re: query can we
•  Re: Disbale edit
•  Re: How to get all the properties values of an object
•  Re: Catalog
•  Re: DHTML drop down menu
•  Re: Where do I find source code on this site?
•  Re: I need help with date validation


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010