• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 75
  • Last Modified:

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?
0
Graeme
Asked:
Graeme
  • 23
  • 18
3 Solutions
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
0
 
Graemewebber4technologiesAuthor Commented:
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
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Graemewebber4technologiesAuthor Commented:
No there would be no reason at all, just made it an overall sql

let me match that up
0
 
Graemewebber4technologiesAuthor Commented:
I have put the same SQL in place (change the name to EventIDs), same result
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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>
0
 
Graemewebber4technologiesAuthor Commented:
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

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
sorry, i dont understand
0
 
Graemewebber4technologiesAuthor Commented:
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 <% %>
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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?
0
 
Graemewebber4technologiesAuthor Commented:
I have not, the form code, I was just cleaning up (but missed the tags)
0
 
Graemewebber4technologiesAuthor Commented:
Hi BigMonty, just wondering how you might be going with this :)
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
can you post your updated code?
0
 
Graemewebber4technologiesAuthor Commented:
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

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
i'll try to have a look this afternoon / evening...i got fires galore today at work :)
0
 
Graemewebber4technologiesAuthor Commented:
not a problem at all, cheers, extinguish those first :)
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
0
 
Graemewebber4technologiesAuthor Commented:
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)
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
any javascript errors?

not sure what you mean by "getting through the eventID"....
0
 
Graemewebber4technologiesAuthor Commented:
no javascript errors

eventID is returning a value, the other 2 (eID and email) do not
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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>"
0
 
Graemewebber4technologiesAuthor Commented:
so you are saying there should be many double quotes ??? eg 3 instead of 1 ?
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try copying and pasting the code exactly as I have it
0
 
Graemewebber4technologiesAuthor Commented:
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
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
is this page publicly accessible? it would help to see the rendered code thats actually being written out
0
 
Graemewebber4technologiesAuthor Commented:
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)
0
 
Graemewebber4technologiesAuthor Commented:
Just looking at it, it isnt even showing the correct eventID, its one that is there, but not the correct one
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
looking at your source code, you have some issues. Before doing anything, I want you to ensure there are quotes around each elements attribute for this page. Invalid markup will cause all sorts of issues. Let me say it again, invalid markup will cause all sorts of issues. This should be your first priority.

Here's an example of what's going on:

<input type=hidden name=event238 id=eventID238 value=''>
<input type=submit
            name='register'
            value='Register!'
            onclick='document.getElementById('eventID238').value='238'
            class=inputsubmit>

see on the onclick event, how you're surrounding the entire value of the event with single quotes? then see how you're surrounding the getElementById function with single quotes? what the browser sees is

onclick='document.getElementById('

that's why no value is getting passed over. you are actually getting a javascript error when you click REGISTER, in the future, if you're not sure how to check for JS error messages, just ask! that's why we're here, to help :)

so first step, get valid HTML. it may take some time, but it's a good learning exercise and will save you time in the future. You can validate your HTML online, since you're behind a password protected site, you'll need to view the source and then copy and paste it into the container.

once that's done, you need to adjust your ASP code to use a mix and match of single and double quotes. I would go with the format of using single quotes to surround the entire expression and double quotes within the expression for any other use, so your onclick should look like:

onclick='document.getElementById("eventID238").value="238" '    <-- space added for readability, not needed

remember, in server side vbscript, to print out a double quote is just to double them up:

Response.Write "This is how ""quotes"" work"

good luck!
0
 
Graemewebber4technologiesAuthor Commented:
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


?
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
almost, check your value attribute though:

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

Open in new window

0
 
Graemewebber4technologiesAuthor Commented:
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

0
 
Graemewebber4technologiesAuthor Commented:
updated the form, still the same results
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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?
0
 
Graemewebber4technologiesAuthor Commented:
Sorry, was trying out the other code, will take it off for you to retry
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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>")
0
 
Graemewebber4technologiesAuthor Commented:
I have put that line back for you
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
I only see one line writing out, are you looping through all of the IDs?

if you are, how many results do you get back if you run the following in the database?

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

you're either not looping correctly or you have only one ID coming back from your sql

it would help to see the latest code you're using for processing the data
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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.
0
 
Graemewebber4technologiesAuthor Commented:
Sorry! been flat out with new contracts for next year

I am going to have a look at this today
0
 
Graemewebber4technologiesAuthor Commented:
OK think I may have found something that shouldn't be int he Query (event_prereg=TRUE), so I have removed that (as this is a temporary value)

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

Open in new window


I have tested this, and this is now showing all the events (from todays date)

Just testing some more code as I think its sort of working :)
0
 
Graemewebber4technologiesAuthor Commented:
I have it working! Cheers mate! the removal of the (event_prereg=TRUE) worked! :)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 23
  • 18
Tackle projects and never again get stuck behind a technical roadblock.
Join Now