Solved

input form not working

Posted on 2016-09-16
41
49 Views
Last Modified: 2016-10-25
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
Comment
Question by:Graeme
  • 23
  • 18
41 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 41801945
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
 

Author Comment

by:Graeme
ID: 41801953
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41801964
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
 

Author Comment

by:Graeme
ID: 41801968
No there would be no reason at all, just made it an overall sql

let me match that up
0
 

Author Comment

by:Graeme
ID: 41801973
I have put the same SQL in place (change the name to EventIDs), same result
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41801988
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
 

Author Comment

by:Graeme
ID: 41801994
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41801997
sorry, i dont understand
0
 

Author Comment

by:Graeme
ID: 41802000
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41802006
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
 

Author Comment

by:Graeme
ID: 41802008
I have not, the form code, I was just cleaning up (but missed the tags)
0
 

Author Comment

by:Graeme
ID: 41809005
Hi BigMonty, just wondering how you might be going with this :)
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41809012
can you post your updated code?
0
 

Author Comment

by:Graeme
ID: 41809020
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41809068
i'll try to have a look this afternoon / evening...i got fires galore today at work :)
0
 

Author Comment

by:Graeme
ID: 41809071
not a problem at all, cheers, extinguish those first :)
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41809338
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
 

Author Comment

by:Graeme
ID: 41810212
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41810710
any javascript errors?

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

Author Comment

by:Graeme
ID: 41810912
no javascript errors

eventID is returning a value, the other 2 (eID and email) do not
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 32

Expert Comment

by:Big Monty
ID: 41813033
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
 

Author Comment

by:Graeme
ID: 41814826
so you are saying there should be many double quotes ??? eg 3 instead of 1 ?
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41815118
try copying and pasting the code exactly as I have it
0
 

Author Comment

by:Graeme
ID: 41815343
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41816043
is this page publicly accessible? it would help to see the rendered code thats actually being written out
0
 

Author Comment

by:Graeme
ID: 41816233
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
 

Author Comment

by:Graeme
ID: 41816238
Just looking at it, it isnt even showing the correct eventID, its one that is there, but not the correct one
0
 
LVL 32

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 41816281
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
 

Author Comment

by:Graeme
ID: 41816301
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41816325
almost, check your value attribute though:

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

Open in new window

0
 

Author Comment

by:Graeme
ID: 41816332
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
 

Author Comment

by:Graeme
ID: 41816335
updated the form, still the same results
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41816503
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
 

Author Comment

by:Graeme
ID: 41817253
Sorry, was trying out the other code, will take it off for you to retry
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 41817914
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
 

Author Comment

by:Graeme
ID: 41818218
I have put that line back for you
0
 
LVL 32

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 41818291
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
 
LVL 32

Expert Comment

by:Big Monty
ID: 41839259
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
 

Author Comment

by:Graeme
ID: 41846164
Sorry! been flat out with new contracts for next year

I am going to have a look at this today
0
 

Accepted Solution

by:
Graeme earned 0 total points
ID: 41851732
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
 

Author Closing Comment

by:Graeme
ID: 41858225
I have it working! Cheers mate! the removal of the (event_prereg=TRUE) worked! :)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses four methods for overlaying images in a container on a web page
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now