Avatar of Graeme McGilvray
Graeme McGilvray
Flag for Australia asked on

input form not working

Hi All, I have copied some working code from 1 page to another, but I cant seem to get it to work

form
<%
Set PreRegister=oConn.Execute("SELECT * FROM events,locations,codes WHERE event_location=location_ID AND event_code=code_short AND event_code<>'TEST' AND event_code<>'SPEC' AND code_live=TRUE AND event_live=TRUE AND event_start>Now() AND event_prereg=TRUE")
%>
<input type=text name=email"&PreRegister("event_ID")&" value='' size=26 placeholder='Email Address' class=inputbox>
<input type=hidden name=event"&PreRegister("event_ID")&" id=eventID"&PreRegister("event_ID")&" value=''>
<input type=submit name='register' value='Register!' onclick='document.getElementById('eventID"&PreRegister("event_ID")&"').value='"&PreRegister("event_ID")&"'' class=inputsubmit>

Open in new window


sql query
If Request.Form("register")="Register!" Then
	Set EventIDs=oConn.Execute("SELECT * FROM events")
	Do Until EventIDs.EOF
	eventID=EventIDs("event_ID")
	eID=Request("event"&eventID)
	email=Request("email" & eventID)
	If eID<>"" and isNumeric(eID) Then
'	check if email address exists
		Set checkemailexist=oConnAE.Execute("SELECT * FROM pax_contacts,pax_register WHERE pax_contacts.pax_ID=pax_register.pax_ID AND event_ID="&eID&" AND pax_contact='"&email&"'")
		If Not checkemailexist.EOF Then
			Response.Write("Your email address has already registered for this event")
		Else
' send email to client saying thank you for signing up for the news letter and opportunity to complete user account.
			oConnAE.Execute("INSERT INTO pax(pax_fname) VALUES('GP Fan')")
			Set NewPax=oConnAE.Execute("SELECT @@IDENTITY AS New_Pax_ID")
			PaxID=Cstr(NewPax("New_Pax_ID"))
			oConnAE.Execute("INSERT INTO pax_contacts(pax_ID,contact_type,pax_contact,contact_primary) VALUES("&PaxID&",2,'"&email&"',TRUE)")
			oConnAE.Execute("INSERT INTO pax_register(pax_ID,event_ID,reg_date,reg_time) VALUES("&PaxID&","&eID&","&Now()&","&Time()&")")
			Response.Write("email check works and no email in db")
		End If
	End If
	EventIDs.MoveNext
		Loop
End If

Open in new window


For some reason I cannot get Lines 5 & 6 to work, help please?
ASPHTML

Avatar of undefined
Last Comment
Graeme McGilvray

8/22/2022 - Mon
Big Monty

what isn't "working"? please be more specific.

Also, I noticed you're not surrounding your html attribute values with single or double quotes. This can yield unexpected behavior if you have bad HTML. Please correct that first (as I've mentioned in previous questions) so we can eliminate any potential errors caused by invalid html
Graeme McGilvray

ASKER
yes, sorry I am going through my code and adding (there is a few thousand lines)

What I am finding is that after i submit the email address, these items:
      eID=Request("event"&eventID)
      email=Request("email" & eventID)

Are not populating, therefore the following IF statement does not work

I have just added in all the Quotes for this effected section and tested, same result as above
Big Monty

in your form code, you have the following query:

Set PreRegister=oConn.Execute("SELECT * FROM events,locations,codes WHERE event_location=location_ID AND event_code=code_short AND event_code<>'TEST' AND event_code<>'SPEC' AND code_live=TRUE AND event_live=TRUE AND event_start>Now() AND event_prereg=TRUE")

 from what I can see, you're building text fields and giving them unique NAMES by using the eventID from your database. You're only using certain eventIDs based off of the where clause.

in your processing code (the second block of code), you're using a different query to get the eventIDs:

Set EventIDs=oConn.Execute("SELECT * FROM events")

my guess is that, since you do not have a where clause like you do in your form code, you are getting some eventIDs that weren't used in your form code (based off of your where clause). Is there any reason why you can't use the same sql in both sections?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Graeme McGilvray

ASKER
No there would be no reason at all, just made it an overall sql

let me match that up
Graeme McGilvray

ASKER
I have put the same SQL in place (change the name to EventIDs), same result
Big Monty

This line doesn't look right to me, on your form page:

<input type=submit name='register' value='Register!' onclick='document.getElementById('eventID"&PreRegister("event_ID")&"').value='"&PreRegister("event_ID")&"'' class=inputsubmit>

looks like you forgot your ASP tags for the onclick event, so it should be:

<input type=submit name='register' value='Register!' onclick='document.getElementById('eventID<%=PreRegister("event_ID")%>').value='<%=PreRegister("event_ID")%>' class=inputsubmit>
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Graeme McGilvray

ASKER
Ah yes, they dont have them in there because they are part of a bigger area:
<%
MainArea=MainArea&"<td width=240 height=80 valign=middle align=center colspan=3><input type='text' name='email"&PreRegister("event_ID")&"' value='' size=26 placeholder='Email Address' class='inputbox'></td>"
MainArea=MainArea&"</tr>"
MainArea=MainArea&"<tr>"
MainArea=MainArea&"<td width=240 height=60 valign=middle align=center colspan=3><input type='hidden' name='event"&PreRegister("event_ID")&"' id='eventID"&PreRegister("event_ID")&"' value=''><input type='submit' name='register' value='Register!' onclick='document.getElementById('eventID"&PreRegister("event_ID")&"').value='"&PreRegister("event_ID")&"'' class='inputsubmit'></td>"
MainArea=MainArea&"</tr>"
MainArea=MainArea&"<tr>"
MainArea=MainArea&"<td width=240 height=180 valign=middle align=center colspan=3>Please provide your email to be notified when tickets / packages for the <b>"&EventName&"</b> are released.</td>"
%>

Open in new window

Big Monty

sorry, i dont understand
Graeme McGilvray

ASKER
MainArea is part of a page layout, and depending on the Query then the result is different MainArea 's

so majority of the page is within <% %>
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Big Monty

ok but the html tags in the form code you posted above did not seem to be. Did you try changing it to what I have?
Graeme McGilvray

ASKER
I have not, the form code, I was just cleaning up (but missed the tags)
Graeme McGilvray

ASKER
Hi BigMonty, just wondering how you might be going with this :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Big Monty

can you post your updated code?
Graeme McGilvray

ASKER
sure can:

Form:
MainArea=MainArea&"<tr>"
MainArea=MainArea&"<td width=240 height=80 valign=middle align=center colspan=3><input type='text' name='email"&PreRegister("event_ID")&"' value='' size=26 placeholder='Email Address' class='inputbox'></td>"
MainArea=MainArea&"</tr>"
MainArea=MainArea&"<tr>"
MainArea=MainArea&"<td width=240 height=60 valign=middle align=center colspan=3><input type='hidden' name='event"&PreRegister("event_ID")&"' id='eventID"&PreRegister("event_ID")&"' value=''><input type='submit' name='register' value='Register!' onclick='document.getElementById('eventID"&PreRegister("event_ID")&"').value='"&PreRegister("event_ID")&"'' class='inputsubmit'></td>"
MainArea=MainArea&"</tr>"
MainArea=MainArea&"<tr>"
MainArea=MainArea&"<td width=240 height=180 valign=middle align=center colspan=3>Please provide your email to be notified when tickets / packages for the <b>"&EventName&"</b> are released.</td>"
MainArea=MainArea&"</tr>"

Open in new window


Submit:
If Request.Form("register")="Register!" Then
'	Response.Write("request.form works")
'	Set EventIDs=oConn.Execute("SELECT * FROM events")
	Set EventIDs=oConn.Execute("SELECT * FROM events,locations,codes WHERE event_location=location_ID AND event_code=code_short AND event_code<>'TEST' AND event_code<>'SPEC' AND code_live=TRUE AND event_live=TRUE AND event_start>Now() AND event_prereg=TRUE")
	Do Until EventIDs.EOF
	eventID=EventIDs("event_ID")
	eID=Request("event"&eventID)
	email=Request("email"&eventID)
	Response.Write(eventID&"-"&eID&"-"&email&"<br>")
	If eID<>"" and isNumeric(eID) Then
		Response.Write("if statement works")
'		check if email address exists
		Set checkemailexist=oConnAE.Execute("SELECT * FROM pax_contacts,pax_register WHERE pax_contacts.pax_ID=pax_register.pax_ID AND event_ID="&eID&" AND pax_contact='"&email&"'")
      		If Not checkemailexist.EOF Then
			Response.Write("email check works and email in db")
		Else
			Response.Write("email check works and no email in db")
			oConnAE.Execute("INSERT INTO pax(pax_fname) VALUES('GP Fan')")
			Set NewPax=oConnAE.Execute("SELECT @@IDENTITY AS New_Pax_ID")
			PaxID=Cstr(NewPax("New_Pax_ID"))
			oConnAE.Execute("INSERT INTO pax_contacts(pax_ID,contact_type,pax_contact,contact_primary) VALUES("&PaxID&",2,'"&email&"',TRUE)")
			oConnAE.Execute("INSERT INTO pax_register(pax_ID,event_ID,reg_date,reg_time) VALUES("&PaxID&","&eID&","&Now()&","&Time()&")")
		End If
	End If
	EventIDs.MoveNext
		Loop
End If

Open in new window

Big Monty

i'll try to have a look this afternoon / evening...i got fires galore today at work :)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Graeme McGilvray

ASKER
not a problem at all, cheers, extinguish those first :)
Big Monty

this line has an extra single quote:

MainArea=MainArea&"<td width=240 height=60 valign=middle align=center colspan=3><input type='hidden' name='event"&PreRegister("event_ID")&"' id='eventID"&PreRegister("event_ID")&"' value=''><input type='submit' name='register' value='Register!' onclick='document.getElementById('eventID"&PreRegister("event_ID")&"').value='"&PreRegister("event_ID")&"''   <-- right here    class='inputsubmit'></td>"

fix that and see if it makes a difference. if not, check to see if you're getting any javascript errors on submit
Graeme McGilvray

ASKER
Hi BigMonty, I have removed the extra quote and have tried again

I am getting through the eventID, not eID or email (all on line 9)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Big Monty

any javascript errors?

not sure what you mean by "getting through the eventID"....
Graeme McGilvray

ASKER
no javascript errors

eventID is returning a value, the other 2 (eID and email) do not
Big Monty

found another issue with invalid quotes on your form, see how important getting quotes are? :)

use:

MainArea=MainArea&"<td width=240 height=60 valign=middle align=center colspan=3><input type='hidden' name='event"&PreRegister("event_ID")&"' id='eventID"&PreRegister("event_ID")&"' value=''><input type='submit' name='register' value='Register!' onclick='document.getElementById(""eventID"&PreRegister("event_ID")&""").value="""&PreRegister("event_ID")&""";' class='inputsubmit'></td>"
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Graeme McGilvray

ASKER
so you are saying there should be many double quotes ??? eg 3 instead of 1 ?
Big Monty

try copying and pasting the code exactly as I have it
Graeme McGilvray

ASKER
I have copied the code and replaced mine where necessary

I am still getting the same result.

eventID is returning a value, the other 2 (eID and email) do not
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Big Monty

is this page publicly accessible? it would help to see the rendered code thats actually being written out
Graeme McGilvray

ASKER
Not publically yet, however I will  PM you a user and pass

http://dev.gptouring.com.au/?code=F1

at the very top of the page shows the eventID, then the 2 dashes below them is the eID  and emailID (which both should be after the dash)
Graeme McGilvray

ASKER
Just looking at it, it isnt even showing the correct eventID, its one that is there, but not the correct one
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
Big Monty

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Graeme McGilvray

ASKER
Hi BigMonty, just so i completely understand (as I have put in alot of quotes, but still not all)

from:
<%
MainArea=MainArea&"<input onclick='document.getElementById('eventID"&EventGP("event_ID")&"').value='"&EventGP("event_ID")&"'>"
%>

Open in new window


to:
<%
MainArea=MainArea&"<input onclick='document.getElementById(""eventID"&EventGP("event_ID")&"""').value='"&EventGP("event_ID")&" '>"
%>

Open in new window


?
Big Monty

almost, check your value attribute though:

onclick='document.getElementById(""eventID"&EventGP("event_ID")&"""').value="""&EventGP("event_ID")&""" '

Open in new window

Graeme McGilvray

ASKER
actually i think there was 1 extra single quote in there, that didnt need to be :P

should be:
onclick='document.getElementById(""eventID"&EventGP("event_ID")&""").value="""&EventGP("event_ID")&""" '

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Graeme McGilvray

ASKER
updated the form, still the same results
Big Monty

can't hit the site, getting:

Microsoft VBScript runtime error '800a01fa'

Class not defined: 'aspJSON'

/home.asp, line 126

are you missing an include file or something?
Graeme McGilvray

ASKER
Sorry, was trying out the other code, will take it off for you to retry
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Big Monty

looking in Developer Tools, I see the data is being passed over, so that's good.

in your form processing code, can you uncomment (or put back) the following line of code so I can see what's happening there?

Response.Write(eventID&"-"&eID&"-"&email&"<br>")
Graeme McGilvray

ASKER
I have put that line back for you
SOLUTION
Big Monty

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Big Monty

How are we making out on this? I only ask because EE is asking me to recommend a closing option since it's neglected in their eyes.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Graeme McGilvray

ASKER
Sorry! been flat out with new contracts for next year

I am going to have a look at this today
ASKER CERTIFIED SOLUTION
Graeme McGilvray

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Graeme McGilvray

ASKER
I have it working! Cheers mate! the removal of the (event_prereg=TRUE) worked! :)