|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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:
|
|
#2
|
|||
|
|||
|
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!
|
|
#3
|
||||
|
||||
|
-->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 |
|
#4
|
|||
|
|||
|
Quote:
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. |
|
#5
|
||||
|
||||
|
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!!! |
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||
|
|||
|
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. |
|
#8
|
|||
|
|||
|
Does that pop up an alert to the user or simply display it on the page?
|
|
#9
|
||||
|
||||
|
Quote:
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
|
|
#10
|
|||
|
|||
|
Quote:
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? |
|
#11
|
||||
|
||||
|
Any chance you can post your entire code for that page so I can see what is happening?
|
|
#12
|
|||
|
|||
|
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
%>
|
|
#13
|
||||
|
||||
|
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? |
|
#14
|
|||
|
|||
|
Quote:
|