-
Senior Member
Last edited by littleMatt; 12-02-2005 at 10:14 AM.
-
?
the error: "Unterminated string constant" occurs in /commentstest/commentsCopy.asp, line 24 where the line is "Response.Redirect("thanks.asp);"
When you do a response.redirect, you should include both opening and closing quotations, e.g. Response.Redirect("thanks.asp");
-
Senior Member
Someone used the Comments form. The details are as follows:
Name: tonytryout
Comments
undefined
Powered by whatever
Have I broken the comments part lol?
Code:
var objName = String(Request.Form("Name"));
var objComments = String(Request.Form("Comments")).replace(/\n/g,"<BR>");
var mainBody = "Someone used the Comments form. The details are as follows:<BR>";
mainBody = mainBody + "<BR><BR><b>Name:</b> " + objName
mainBody = mainBody + "<BR><BR><b>Comments</b><BR><BR>" + String(Request.Form("Comments")).replace(/\n/g,"<BR>") + "</P><BR>";
var endBody = mainBody + "<BR><BR>Powered by whatever";
Last edited by littleMatt; 12-02-2005 at 10:30 AM.
-
?
lol, checking the code again.... ok
the comments paramter name is 'textarea' as shown here:
Code:
<textarea name="textarea" cols="23" rows="4" wrap="PHYSICAL" id="textarea"></textarea>
But the ASP code is looking for a parameter name called 'Comments'
Code:
String(Request.Form("Comments")).replace(/\n/g,"<BR>")
So basically the code couldn't find a parameter called "Comments" so it failed and returned a value of "undefined".
btw, MSDN has a very good info for ASP, see here for example with your previous error
-
Senior Member
Right! The comments are now working.
I tried to add an email parameter:
var objEmail = String(Request.Form("Email"));
but it didn't work. It seemed to confuse the two text fields, so email address would come through as name
-
?
how do you mean? Are the parameters different for Name and Email?
-
Senior Member
Sorry, I did it wrong:
var objName = String(Request.Form("Name"));
var objEmail = String(Request.Form("Email")); I added this...
var objComments = String(Request.Form("Comments")).replace(/\n/g,"<BR>");
var mainBody = "Someone used the Comments form. The details are as follows:<BR>";
mainBody = mainBody + "<BR><BR><b>Name:</b> " + objName
mainBody = mainBody + "<BR><BR><b>Email:</b> " + objEmail but not this..
mainBody = mainBody + "<BR><BR><b>Comments</b><BR><BR>" + String(Request.Form("Comments")).replace(/\n/g,"<BR>") + "</P><BR>";
var endBody = mainBody + "<BR><BR>Powered by whatever";
Just waiting for the test mail to come through now.
-
?
ah cool!
let me know how it goes....
*prepares invoice*
-
Senior Member
Will do... It's taking ages though, I haven't done anything in that code that would make it all stop working have I?
Hehe, np - I was gonna ask if you wanted me to put your logo at the bottom of the page and like to your folio site?
-
?
strange -- can you post full code here and I will have a look.
-
Senior Member
Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
if (String(Request("send_email")) != "undefined") {
var objName = String(Request.Form("Name"));
var objEmail = String(Request.Form("Email"));
var objComments = String(Request.Form("Comments")).replace(/\n/g,"<BR>");
var mainBody = "Someone used the Comments form. The details are as follows:<BR>";
mainBody = mainBody + "<BR><BR><b>Name:</b> " + objName
mainBody = mainBody + "<BR><BR><b>Email:</b> " + objEmail
mainBody = mainBody + "<BR><BR><b>Comments</b><BR><BR>" + String(Request.Form("Comments")).replace(/\n/g,"<BR>") + "</P><BR>";
var endBody = mainBody + "<BR><BR>Powered by whatever";
var objCDO = Server.CreateObject("CDONTS.NewMail");
objCDO.To = "matt@fishandonions.com"
objCDO.From = "website@fishandonions.com"
objCDO.Subject = "Comments"
objCDO.Body = endBody
objCDO.MailFormat = 0
objCDO.BodyFormat = 0
objCDO.Send()
objCDO = null
}
%>
<html>
<head>
<title>comments</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
-->
</style>
</head>
<body background="http://www.fishandonions.com/images/back.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form action="comments.asp" method="post" name="frmComments">
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<table width="350" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="50"> <div align="center">
<p align="center"><span class="bodyCopy"><font color="#000000" size="2" face="Georgia, Times New Roman, Times, serif">name</font></span><br>
<input name="Name" type="text" id="Name" size="26">
</p>
</div></td>
</tr>
<tr>
<td height="50"> <div align="center">
<p align="center"><span class="bodyCopy"><font color="#000000" size="2" face="Georgia, Times New Roman, Times, serif">email
address</font></span><br>
<input name="Email" type="text" id="Email" size="26">
</p>
</div></td>
</tr>
<tr>
<td width="100"> <div align="center">
<p align="center"><span class="bodyCopy"><font color="#000000" size="2" face="Georgia, Times New Roman, Times, serif">comments</font></span><br>
<font size="2">(please specify which image you are commenting
on)</font><br>
<textarea name="Comments" cols="26" rows="4" wrap="PHYSICAL" id="Comments"></textarea>
<input name="send_email" type="hidden" id="send_email" value="true">
<br>
<input type="submit" name="Submit" value="Send">
</p>
</div></td>
</tr>
</table>
</div>
<p align="center">
<input name="pageinfo" type="hidden" id="pageinfo" value="Products page">
</p>
<p align="center"><span class="bodyCopy"><font color="#000000" size="2" face="Georgia, Times New Roman, Times, serif">thank
you</font></span><font size="2"><br>
comments may take some time to appear on the web page. please close
this window after submitting.</font></p></td>
</tr>
</table>
</form>
</body>
</html>
Do you want me to link you up? Or you embarrassed to be associated with my site lol
-
Senior Member
Someone used the Comments form. The details are as follows:
Name: this is my name
Email: this is my email address
Comments
this is my comment
Powered by whatever
Perfect!
Mate, thank you so much. I really REALLY appreciate your help! You have the patience of a Saint!
-
?
try commenting out the objEmail bit, e.g.
Code:
// var objEmail = String(Request.Form("Email"));
And modify:
Code:
mainBody = mainBody + "<BR><BR><b>Email:</b> " + objEmail
to
Code:
mainBody = mainBody + "<BR><BR><b>Email:</b> " + String(Request.Form("Email"));
lol, yeah, the logo bit sounds good!
-
?
np, just glad that I was able to help.
at least it's a nice change from doing it for demanding clients.
btw, you may want to do some validation checks before the email is actually sent. The easiest/quickest way is to use Dreamweaver's built-in form validation
-
Senior Member
here you go
What will validation checks do?
-
?
cool thanks mate
must go over to my parents now before traffic gets too crazy but will show you later how to do the validation checks.
Last edited by tonytryout; 12-05-2005 at 11:06 AM.
Reason: spotted a typo
-
?
re validation checks... like I said earlier, the easiest and quickest way is to use a client-side javascript version facility provided by Dreamweaver. Bear in mind, this only works if your user has JavaScript enabled but this should suffice for your needs (if you need a more advanced one, let me know).
In code view, put your mouse cursor in the form tag (e.g. <|form....> then click Tag Inspector and you should see "Behaviour" tab.
Click the + icon and you should see "Validate Form". Clicking it will then bring up a window containing your form fields and whether/how you want them validated.
There is also a nice slightly better/more advanced form validation version (you can customise error message, etc.) provided by Yaromat which you can use if you wish.
On a side note, "comments (please specify which image you are commenting on)" in your form -- why not put in a dropdown field for image names?
Hope this helps.
-
Senior Member
Oooh that's kool! I've set it to close once submitted.
Yeah not sure about the specify bit. So far I have almost 60 images on there, and none of them are really named on the pages so a drop down might be a bit big and confusing for the user. But asking the user to describe what image they are looking isn't that good either. Is there a way for the .asp page to know what page preceded it?
-
?
off the top of my head, create a link with a parameter for each image, e.g. comments.asp?image=fish, comments.asp?image=dog, etc.
Then in comments.asp form, add a new hidden field as shown below:
Code:
<input name="image_name" type="hidden" id="image_name" value="<%=Request.QueryString("image")%>">
What that piece of code does is it gets hold of a value from a paramater specified in the URL (e.g. "image"). So if a user clicks on a dog image, the form would know that the image was of dog.
Don't forgot to add a line of code in your email code for the image name.
-
Senior Member
But how would the comments.asp form know from what page it was opened?
Would it make sense to actually put the form on every single page under the image, the have your hidden field tell me what the page name was (46.html for example)?
Edit: But then every page would have to be an asp page...? Mission lol
Last edited by littleMatt; 12-05-2005 at 01:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|