ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 7th, 2008, 03:28 PM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
How do I escape the ampersand?

I have this:

Code:
<%mySQL = "SELECT Manage_Area_Name FROM CJI_AreaMgrs WHERE Area_Mgr = '" & %> Document.frmUser.Elements("Area_Mgr" & i).Value <% & "'"


And the error I get is:

Quote:
Microsoft VBScript compilation error '800a03ea'

Syntax error

/apps/lms/Includes/master/maslist.asp, line 57

mySQL = "SELECT Manage_Area_Name FROM CJI_AreaMgrs WHERE Area_Mgr = '" &
-------------------------------------------------------------------------------^

Reply With Quote
  #2  
Old May 7th, 2008, 03:41 PM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
Oops, I just realized this is ASP, not vbscript. Can someone please move this to ASP? And please post a reply if you have one! Thanks!

Reply With Quote
  #3  
Old May 8th, 2008, 06:02 AM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
Click here for more information.
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,483 mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)mehere User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 3 Weeks 3 Days 21 h 7 m 11 sec
Reputation Power: 1450
-->Thread moved to ASP Forum

you have extra %> in you code ... try this
Code:
<%mySQL = "SELECT Manage_Area_Name FROM CJI_AreaMgrs WHERE Area_Mgr = '" & Document.frmUser.Elements("Area_Mgr" & i).Value & "'"%>
__________________
Come JOIN the party!!!

Quote of the Month:
Trouble: Luck can't last a lifetime unless you die young.

Questions to Ponder:
Do cemetery workers prefer the graveyard shift?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright© 2008 sbenj69

Reply With Quote
  #4  
Old May 8th, 2008, 07:42 AM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
Quote:
Originally Posted by mehere
-->Thread moved to ASP Forum

you have extra %> in you code ... try this
Code:
<%mySQL = "SELECT Manage_Area_Name FROM CJI_AreaMgrs WHERE Area_Mgr = '" & Document.frmUser.Elements("Area_Mgr" & i).Value & "'"%>

That won't work because the document.formname.elements() only works in vbscript and not ASP (as far as I know). So when I make that change and try to run it, it only loads the page up to that point and then loads nothing else. That's why I was using the <% %> operators to exclude it from the ASP code and let the vbscript function handle it, then continue with the string assignment in ASP.

Reply With Quote
  #5  
Old May 8th, 2008, 08:07 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,025 sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 4 h 38 m 59 sec
Reputation Power: 608
I hate to sound like a broken record, but you will need to post all of the relevant code so that we can see what is going on.

Where is the information coming from? I assume that you are trying to do this in the client-side? If so, I dont think it is possible without AJAX.

Without seeing all of your code or fully understanding what you are trying to achieve, I can only assume that you would be better of posting the contents of the form to another page, eg.
Code:
<form name="myform" action="processinfo.asp" method="post">
<input type="text" name="Area_Mgr">
<input type="submit" name="submit" value="submit">
</form>

Which will submit the info to a page called processinfo.asp, it is on this page that you can use mehere's syntax - but grabbing from the Request.Form collection instead:
Code:
<%
mySQL = "SELECT Manage_Area_Name FROM CJI_AreaMgrs WHERE Area_Mgr = '" & Request.Form("Area_Mgr" & i) & "'"
%>

Apologies if I have mis-understood you, but the better the description of your problem, the better the help you will receive!!!
Comments on this post
mehere agrees: good point SoS
mmltonge agrees: good call

Reply With Quote
  #6  
Old May 8th, 2008, 08:27 AM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
You're right about that, but then when I do the comparison on the second page, how do I post an alert to the user if there is a mismatch? That's the problem I was facing when trying that.

Reply With Quote
  #7  
Old May 8th, 2008, 08:42 AM
mmltonge mmltonge is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 182 mmltonge User rank is Second Lieutenant (5000 - 10000 Reputation Level)mmltonge User rank is Second Lieutenant (5000 - 10000 Reputation Level)mmltonge User rank is Second Lieutenant (5000 - 10000 Reputation Level)mmltonge User rank is Second Lieutenant (5000 - 10000 Reputation Level)mmltonge User rank is Second Lieutenant (5000 - 10000 Reputation Level)mmltonge User rank is Second Lieutenant (5000 - 10000 Reputation Level)mmltonge User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 11 h 18 m 54 sec
Reputation Power: 55
Execute the SQL command then
Code:
If objRec.EOF Then
Response.Write "Your entry was wrong"
Else
Response.Write "Your entry was correct"
End If

Last edited by mmltonge : May 8th, 2008 at 08:45 AM.

Reply With Quote
  #8  
Old May 8th, 2008, 08:58 AM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
Does that pop up an alert to the user or simply display it on the page?

Reply With Quote
  #9  
Old May 8th, 2008, 09:06 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,025 sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 4 h 38 m 59 sec
Reputation Power: 608
Quote:
Originally Posted by EM2
Does that pop up an alert to the user or simply display it on the page?

That simply displays it on the page, but you should be able to embed the javascript within the server-side code something like this:
Code:
If objRec.EOF Then
  %><script>alert("Incorrect");</script><%
Else
  %><script>alert("Correct");</script><%
End If

Or:
Code:
If objRec.EOF Then
  Response.Write("<script>alert(""Incorrect"");</script>")
Else
  Response.Write("<script>alert(""Correct"");</script>")
End If

Reply With Quote
  #10  
Old May 8th, 2008, 09:23 AM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
Quote:
Originally Posted by sync_or_swim
That simply displays it on the page, but you should be able to embed the javascript within the server-side code something like this:
Code:
If objRec.EOF Then
  %><script>alert("Incorrect");</script><%
Else
  %><script>alert("Correct");</script><%
End If

Or:
Code:
If objRec.EOF Then
  Response.Write("<script>alert(""Incorrect"");</script>")
Else
  Response.Write("<script>alert(""Correct"");</script>")
End If


So close but still doesn't work. When I put that code on my first client side page it works. But then if I move it to the page the form is being submitted to, everything works as if it wasn't even there. It appears to just skip it because no alert box pops up, it just submits the form and returns. Any ideas?

Reply With Quote
  #11  
Old May 8th, 2008, 09:45 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,025 sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 4 h 38 m 59 sec
Reputation Power: 608
Any chance you can post your entire code for that page so I can see what is happening?

Reply With Quote
  #12  
Old May 8th, 2008, 09:52 AM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
Thanks a lot. Here's the code for page 2 where the form elements are being submitted. Nothing gets alerted when this is run but everything else works fine.

Code:
<!--#include file="../strConnect.asp"#-->
<%
Dim Con, mySQL, rs_Users, rsupdate, sqlupdate, fldCount, myfield, savewhere, updatetype
Dim RowCount
Set Con = Server.CreateObject( "ADODB.Connection" ) 
Con.Open strConnect
  
updatetype = trim(request("type"))
tablename = Trim(Request.Form("Tablename"))
RowCount = Trim(Request.Form("RowCount"))
rowCount2 = Trim(Request.Form("RowCount2"))

Response.Write RowCount & TableName

Response.Write("<script>alert(""Incorrect"");</script>")
%><script>alert(""Incorrect"");</script><%
  
For x = 1 to RowCount
	If Trim(Request.Form("CHANGED" & x) = "T") Then
		Response.Write x  & " - Has been changed <BR><BR>"
		Call updaterow()
	End If
Next

Function UpdateRow()

  mySQL = "SELECT * FROM " & TableName & ";"
  response.write mysql
  Set rs_Users = Con.Execute( mySQL )

	IF Not rs_Users.EOF then  

		fldCount = rs_Users.Fields.Count
		sqlupdate = "UPDATE " & TableName & " SET " 
	
		For Z = 0 to fldCount - 1
			Set fld =  rs_Users.Fields.item(z)
			myfield = Chr(34) & fld.Name & chr(34)
			
			If Z = 0 then 
			   savewhere = "WHERE " & trim(myfield) & "='" & trim(Request.Form(fld.name & x)) & "';" 
			End if

			sqlupdate = sqlupdate & trim(fld.name) & " =N'" & trim(Request.Form(fld.name & x	))	
			
			IF Z < fldcount - 1 then
				sqlupdate = sqlupdate & "', "
			Else
				sqlupdate = sqlupdate & "' "
			End if
		Next
		Rs_Users.Close
		Response.Write sqlupdate & Savewhere
		  Set rs_Update = Con.Execute( sqlupdate & Savewhere )
	End if

		Response.Write "<BR><BR>" & sqlupdate & Savewhere

End Function

Response.Redirect "maslist.asp?table=" & TableName

%>

Reply With Quote
  #13  
Old May 8th, 2008, 10:06 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,025 sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level)sync_or_swim User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 4 h 38 m 59 sec
Reputation Power: 608
I dont really follow exactly what you are trying to achieve but in terms of the alert boxes, I have copied your code onto my page and the first alert works fine, the second works if you remove the escaped quotes:
Code:
%><script>alert("Incorrect");</script><%

So, one explanation for the alert not showing would be that your code is not hitting that line for some reason, eg. a decision made prior to it.

What happens if you create a new page on your server that contains nothing but:
Code:
<%Response.Write("<script>alert(""Incorrect"");</script>")%>

Do you see the alert?

Reply With Quote
  #14  
Old May 8th, 2008, 10:38 AM
EM2 EM2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 38 EM2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 14 m 43 sec
Reputation Power: 1
Quote:
Originally Posted by sync_or_swim
I dont really follow exactly what you are trying to achieve but in terms of the alert boxes, I have copied your code onto my page and the first alert works fine, the second works if you remove the escaped quotes:
Code:
%><script>alert("Incorrect");</script><%

So, one explanation for the alert not showing would be that your code is not hitting that line for some reason, eg. a decision made prior to it.