Link to home
Create AccountLog in
Avatar of Graeme McGilvray
Graeme McGilvrayFlag 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?
Avatar of Big Monty
Big Monty
Flag of United States of America image

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
Avatar of 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
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?
No there would be no reason at all, just made it an overall sql

let me match that up
I have put the same SQL in place (change the name to EventIDs), same result
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>
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

sorry, i dont understand
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 <% %>
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?
I have not, the form code, I was just cleaning up (but missed the tags)
Hi BigMonty, just wondering how you might be going with this :)
can you post your updated code?
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

i'll try to have a look this afternoon / evening...i got fires galore today at work :)
not a problem at all, cheers, extinguish those first :)
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
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)
any javascript errors?

not sure what you mean by "getting through the eventID"....
no javascript errors

eventID is returning a value, the other 2 (eID and email) do not
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>"
so you are saying there should be many double quotes ??? eg 3 instead of 1 ?
try copying and pasting the code exactly as I have it
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
is this page publicly accessible? it would help to see the rendered code thats actually being written out
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)
Just looking at it, it isnt even showing the correct eventID, its one that is there, but not the correct one
SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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


?
almost, check your value attribute though:

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

Open in new window

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

updated the form, still the same results
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?
Sorry, was trying out the other code, will take it off for you to retry
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>")
I have put that line back for you
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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.
Sorry! been flat out with new contracts for next year

I am going to have a look at this today
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I have it working! Cheers mate! the removal of the (event_prereg=TRUE) worked! :)