form inside a div

form inside a div

am 17.09.2007 22:55:28 von jp2code

I have some Classic ASP script that is not working at all. By that, I mean
that none of the code seems to execute.

I have the exact same code in another form on another web page, and it does
work.

The only difference between the two that I can see (other than username and
password fields) is that the non-working page contains a form within a div
tag, whereas the working page places the form inside a table.

The form's id is "contact" on both pages.
The div's id is "popup" on the non-working page.
The table on the working page does not use an id.

Have I used a reserved word somewhere?
Can a form with an id be nested within another tag that also has an id?

There are no errors. When the form is submitted, the information should be
validated in the script, but instead I get what looks like the page being
reloaded without its previous values.

I am typically a C++ guy, so it is very possible that I have missed or
overlooked something very basic - but it wasn't the username and password!
I've checked them multiple times.

Thanks in advance!
~Joe

Below is the non-functional version's code:
<%@ Language="VBSCRIPT"%>

"http://www.w3.org/TR/html4/strict.dtd">

<%

Dim OK

Dim str1Err, str2Err, str3Err, str4Err

Dim strFirst, strLast, strEmail, strMyMessage

Dim strWriteMsg, strEmailValidator, strHtmlBody

OK = True

str1Err = ""

str2Err = ""

str3Err = ""

str4Err = ""

strMyMessage = ""

strWriteMsg = "Write your message here."

strEmailValidator =
"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} \.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"

If (Request.Form("5submit") = "Send") Then

strFirst = Request.Form("1FirstName")

If (strFirst = "") Then

str1Err = "Required"

OK = False

End If

strLast = Request.Form("2LastName")

If (strLast = "") Then

str2Err = "Required"

OK = False

End If

strEmail = Request.Form("3Email")

Set regEx = New RegExp

regEx.Pattern = "^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w{2,}$"

If (regEx.Test(Trim(strEmail)) = False) Then

str3Err = "Incorrect format"

OK = False

End If

Set regEx = Nothing

strMyMessage = Request.Form("4Message")

If (strMyMessage = "") Or (strMyMessage = strWriteMsg) Then

str4Err = "Required"

OK = False

Else

strWiteMsg = ""

End If

If (OK = True) Then

Dim strFrom

strFrom = strFirst & " " & strLast & " <" & strEmail & ">"

Set objMessage = CreateObject("CDO.Message")

strHtmlBody = " style=""background-image:url(http://www.poolranch.com/images /cattle.jpg);
background-position: 0% 50%; background-repeat: repeat-x;"">" & _

"

" & _

"Pool Ranch
" & _

"From: " & strFirst & " " & strLast & " <" & strEmail & ">" & "
"
& _

"Message:
" & strMyMessage & "
style=""width:150px"">" & _

" Logo"" style=""height:215px; width:185px"">" & _

""


objMessage.Subject = "PoolRanch Contact"

objMessage.From = strFrom

objMessage.To = ' value is hidden

objMessage.HTMLBody = strHtmlBody

objMessage.Configuration.Fields.Item("http://schemas.microso ft.com/cdo/configuration/smtpserver")
= "relay-hosting.secureserver.net"

objMessage.Configuration.Fields.Item("http://schemas.microso ft.com/cdo/configuration/smtpconnectiontimeout")
= 60

objMessage.Configuration.Fields.Update

On Error Resume Next

objMessage.Send

Set objMessage = Nothing

If Err.number = 0 Then

Response.Redirect("../thanks.htm")

Else

strMyMessage = "Send Failed. Your message was not sent. I am so sorry! " & _

"Error # " & CStr(Err.number) & ": " & Err.Description

Err.Clear

End If

End If

Else

strMyMessage = strWriteMsg

if (strMyMessage = "") Then

Response.Write("Your message was not sent.")

end if

End If

%>





Pool Ranch - Contact

title="poolranch style" />









Contact Form











Re: form inside a div

am 18.09.2007 00:04:09 von Dave Anderson

"jp2code" wrote:
> ...the non-working page contains a form within a div tag, whereas
> the working page places the form inside a table.
>
> The form's id is "contact" on both pages.
> The div's id is "popup" on the non-working page.
> The table on the working page does not use an id.
>
> Have I used a reserved word somewhere?

Doubtful. It is almost impossible to do so, provided you enclose the
attribute values in quotes. HOWEVER, you should take a look at the ID
specification:

id = name [CS]
This attribute assigns a name to an element. This name must
be unique in a document.

http://www.w3.org/TR/html401/struct/global.html#adef-id

By drilling down, you will see that [CS] means it is case-sensitive, and
name tokens have few restrictions:

6.2 SGML basic types
ID and NAME tokens must begin with a letter ([A-Za-z]) and may
be followed by any number of letters, digits ([0-9]), hyphens
("-"), underscores ("_"), colons (":"), and periods (".").

http://www.w3.org/TR/html401/types.html#type-name

You are declaring HTML 4.01 strict, so I would not presume your NAME
attributes, like "1FirstName", are not the problem. Fix those first.


> Can a form with an id be nested within another tag that also has an id?

Absolutely.



> There are no errors.

There is no client-side scripting in your example, so I presume you mean you
get none of the feedback messages you create during the post-back. It should
be trivial for you to determine which steps are reached. Do so.



> When the form is submitted, the information should be validated in the
> script, but instead I get what looks like the page being reloaded
> without its previous values.

Are you certain the action of the form is the script itself? If you copied
from a working script, you may still be posting to that script.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Re: form inside a div

am 23.11.2007 01:00:24 von unknown

Hello! Good Site! Thanks you! tgzegwnfvnhqu