View Full Version : spaces in my variables
ghornet
05-01-2003, 10:38 PM
Hi I am trying to pass some VBscript variables through a javascript function like this
<td width="10" onclick=adminmenu(<%= rs("ContactID")%>,<%=rs("RO")%>,"<%= rs("FirstName")%>","<%= rs("LastName") %>")><IMG height="10" class="image" width="10" src="../images/littlecheck.gif"></td>
the problem is that some of the last names have spaces ie: Loyd Jr.
and I think this is causing an unterminated string constant error, what can I do to fix this?
D--
mordred
05-01-2003, 11:01 PM
You don't put the quotes around the value (i.e. the JavaScript statement) of your onclick attribute, that is causing the error.
ghornet
05-01-2003, 11:08 PM
onclick=" adminmenu(<%= rs("ContactID")%>,<%=rs("RO")%>,"<%= rs("FirstName")%>","<%= rs("LastName") %>")" ><
ghornet
05-01-2003, 11:11 PM
So from what you are saying my statement should look like this?
onclick=adminmenu(<%= rs("ContactID")%>,<%=rs("RO")%>,<%= rs("FirstName")%>,<%= rs("LastName") %>)
when i do this I get an unterminated string constant on this line
<td width="10" onclick=adminmenu(224395,807600,Patrick,O'Brien)><IMG height="10" class="image" width="10" src="../images/littlecheck.gif"></td>
beetle
05-01-2003, 11:25 PM
I think he was saying "you didn't" - because when I look at your first post...you, erm, didn't.
ghornet
05-01-2003, 11:28 PM
did'nt don't arg... I have tried every which way I can imagine... I have variables that might have a " " space in them or might have a ' in them... what is the best way to pass those through the function
D--
beetle
05-01-2003, 11:38 PM
Okay, lets start with a c&p of your first post<td width="10" onclick=adminmenu(<%= rs("ContactID")%>,<%=rs("RO")%>,"<%= rs("FirstName")%>","<%= rs("LastName") %>")><IMG height="10" class="image" width="10" src="../images/littlecheck.gif"></td>Now, I'll replace all the ASP with some made-up data<td width="10" onclick=adminmenu(1,2,"Peter","Bailey")><IMG height="10" class="image" width="10" src="../images/littlecheck.gif"></td>Now, this looks okay, but is really incorrect. What we SHOULD use is<td width="10" onclick="adminmenu(1,2,'Peter','Bailey')"><IMG height="10" class="image" width="10" src="../images/littlecheck.gif"></td>
ghornet
05-01-2003, 11:45 PM
Ok I got that down... I think what was really screwing with me is the fact that I have a name like O'Brien and that is causing it to error out, I am trying to write a little loop that will catch this and replace it with a space... is there an easier way to deal with this?
D--
Thank you very much for you help.. sorry I got frustrated.
ghornet
05-01-2003, 11:53 PM
LastName = rs("LastName")
'This gets ride of the pesky ' in O'brien that was screwing up my code
if InStr(rs("LastName"),"'") then
LastName = rs("LastName")
LastName = Replace(LastName,"'","")
Dont know if this is the best way but it seems to work
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.