Forums
This topic is locked
Apostrophes in set text - catch 22?
Posted 19 Jun 2003 11:05:50
1
has voted
19 Jun 2003 11:05:50 Dave Desormeaux posted:
I have a page displaying photos and I am using the mouseover behavior "set text in layer" to display the description of that image in a layer (data is being called from Descriptions field in an MS ACCESS 2000 DB).The text appears, but ONLY if there is no apostrophe in the content on the DB.
If I manually relplace all instances of " ' " with "\'", that works, but then when the same description is displayed using regular URL parameters, the backslash shows up - which I don't want!!
IS there a way of leaving the apostrophes in the DB but somehow replacing the character before it is loaded on to the browser?
Perhaps a javascript fix??
I am totally stumped on this one...
Thanks
Replies
Replied 19 Jun 2003 13:53:31
19 Jun 2003 13:53:31 Owen Eastwick replied:
You need to replace single quotes with two single quotes when you insert the text into the DB.
If you look at the code DW generates you will see a lot of these:
Replace(rsWhatever__MMColParam, "'", "''"
If you are not using DW's standard insert behaviour, you can do something similar yourself:
varText = Replace(Request("TextFieldName"
, "'", "''"
Regards
Owen.
-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
If you look at the code DW generates you will see a lot of these:
Replace(rsWhatever__MMColParam, "'", "''"

If you are not using DW's standard insert behaviour, you can do something similar yourself:
varText = Replace(Request("TextFieldName"


Regards
Owen.
-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm
Developer services and tutorials: www.drdev.net
Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
Replied 19 Jun 2003 17:27:34
19 Jun 2003 17:27:34 Dave Desormeaux replied:
Thanks for the reply Owen. I am using the standard insert behavior and it works fine. Inserts are working properly. My problem is
specifically with the mouseover behavior (set text in layer).
For instance, when I pass a URL parameter to display a <u>single</u> image on a page, and use that same parameter to display the description text in a text box or layer, everything is fine. No mouseover, no problem.
I'm not sure if this code will show up properly but I will include examples.
EXAMPLE 1
<form name="form1" method="POST" action="/edit.asp?photoid=174">
<input type="text" name="textfield1" size="110" value="Valley of the Temple's in Agrigento, Sicily" maxlength="110">
However, if I have multiple images on the page containing the mouseover behaviour, two things happen:
1. I get a runtime error (in IE6 at least) that reads: ERROR: Expected ')'
I get this error for each instance the page enccounters an image whose description has an apostrophe
2. When I pass the cursor over each image, for those images with an apostrophe in the description, nothing is displayed in the layer. No text at all. The layer remains blank until the cursor rolls over an image whose description does not contain an apostrophe.
EXAMPLE 2
asp code reads:
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#999999"><a
href="photos/<%=rsPhotos.Fields.Item("filename"
.Value%>"><img border="0"
src="thumbs/<%=(rsPhotos.Fields.Item("thumbname"
.Value)%>" vspace="2" hspace="1"
onMouseOver="MM_setTextOfLayer('Layer1','','<%=(rsPhotos.Fields.Item("description"
.Value)%>')"></a>
HTML output for each returned image reads:
<a href="photos/valley16.jpg"><img border="0" src="thumbs/valley16_t.jpg" vspace="2" hspace="1"
onMouseOver="MM_setTextOfLayer('Layer1','','On the road to Valley of the Temples. Agrigento, Sicily')"></a>
SOLUTION?
If I double-click on the Dynamic Attribute(img.onMouseover,rsPhotos.description), I can see the menu for Format. It seems to me that one of these should solve my problem but I'm not sure.
Hope I'm explaining myself clearly.
Thanks
Dave
specifically with the mouseover behavior (set text in layer).
For instance, when I pass a URL parameter to display a <u>single</u> image on a page, and use that same parameter to display the description text in a text box or layer, everything is fine. No mouseover, no problem.
I'm not sure if this code will show up properly but I will include examples.
EXAMPLE 1
<form name="form1" method="POST" action="/edit.asp?photoid=174">
<input type="text" name="textfield1" size="110" value="Valley of the Temple's in Agrigento, Sicily" maxlength="110">
However, if I have multiple images on the page containing the mouseover behaviour, two things happen:
1. I get a runtime error (in IE6 at least) that reads: ERROR: Expected ')'
I get this error for each instance the page enccounters an image whose description has an apostrophe
2. When I pass the cursor over each image, for those images with an apostrophe in the description, nothing is displayed in the layer. No text at all. The layer remains blank until the cursor rolls over an image whose description does not contain an apostrophe.
EXAMPLE 2
asp code reads:
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#999999"><a
href="photos/<%=rsPhotos.Fields.Item("filename"

src="thumbs/<%=(rsPhotos.Fields.Item("thumbname"

onMouseOver="MM_setTextOfLayer('Layer1','','<%=(rsPhotos.Fields.Item("description"

HTML output for each returned image reads:
<a href="photos/valley16.jpg"><img border="0" src="thumbs/valley16_t.jpg" vspace="2" hspace="1"
onMouseOver="MM_setTextOfLayer('Layer1','','On the road to Valley of the Temples. Agrigento, Sicily')"></a>
SOLUTION?
If I double-click on the Dynamic Attribute(img.onMouseover,rsPhotos.description), I can see the menu for Format. It seems to me that one of these should solve my problem but I'm not sure.
Hope I'm explaining myself clearly.
Thanks
Dave
Replied 24 Jun 2003 14:38:09
24 Jun 2003 14:38:09 Dave Desormeaux replied:
I think I need to clarify what I'm trying to do...cause I really need help....
First of all, when writing to the database, single quotes have been replaced by double quotes - using DW's standard insert behaviour. No problem there.
The issue....
Basically, I am using the SET TEXT IN LAYER behavior when I mouseover an image.
Instead of writing in a piece of set text, I am using a querystring to generate the text from a column in my db.
The querystring is getting data from a MEMO field in access db. This is that piece of code:
<a href="photodetail.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "photoid=" & rsPhotos.Fields.Item("photoid"
.Value %>">
<img border="1" src="thumbs/<%=(rsPhotos.Fields.Item("thumbname"
.Value)%>" vspace="2" hspace="1" onMouseOver="MM_setTextOfLayer('Layer1','','<%=(rsPhotos.Fields.Item("description"
.Value)%>')">
</a>
When the page loads in the browser, I get this error:
ERROR: Expected ')'
Line 55
This error repeats each time it encounters the apostrophe from the same column in the db.
After clicking "no" to debug, the page loads.
I get this HTML for that image:
<a href="photos/valley16.jpg"><img border="0" src="thumbs/valley16_t.jpg" vspace="2" hspace="1"
onMouseOver="MM_setTextOfLayer('Layer1','','On the road the temples' valley. Agrigento, Sicily')"></a>
The wierd thing is that an apostrophe shows up in the HTML, but in the browser, when the cursor rolls over, there is no text displayed in the layer.
So there are really two problems, which I assume are connected:
1) the error message
2) getting the mouseover to show the apostrophe as it has been written to the database
I am totally stumped so any help is most appreciated.
Thanks !!!!!!<b></b>
First of all, when writing to the database, single quotes have been replaced by double quotes - using DW's standard insert behaviour. No problem there.
The issue....
Basically, I am using the SET TEXT IN LAYER behavior when I mouseover an image.
Instead of writing in a piece of set text, I am using a querystring to generate the text from a column in my db.
The querystring is getting data from a MEMO field in access db. This is that piece of code:
<a href="photodetail.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "photoid=" & rsPhotos.Fields.Item("photoid"

<img border="1" src="thumbs/<%=(rsPhotos.Fields.Item("thumbname"


</a>
When the page loads in the browser, I get this error:
ERROR: Expected ')'
Line 55
This error repeats each time it encounters the apostrophe from the same column in the db.
After clicking "no" to debug, the page loads.
I get this HTML for that image:
<a href="photos/valley16.jpg"><img border="0" src="thumbs/valley16_t.jpg" vspace="2" hspace="1"
onMouseOver="MM_setTextOfLayer('Layer1','','On the road the temples' valley. Agrigento, Sicily')"></a>
The wierd thing is that an apostrophe shows up in the HTML, but in the browser, when the cursor rolls over, there is no text displayed in the layer.
So there are really two problems, which I assume are connected:
1) the error message
2) getting the mouseover to show the apostrophe as it has been written to the database
I am totally stumped so any help is most appreciated.
Thanks !!!!!!<b></b>
Replied 25 Jun 2003 08:17:39
25 Jun 2003 08:17:39 Dave Desormeaux replied:
Problems solved.
The offending code was:
<%='(rsPhotos.Fields.Item("description"
.Value)%>
The solution:
<%='Replace(rsPhotos.Fields.Item("description"
.Value,"'","\'"
%>
Duh.
The offending code was:
<%='(rsPhotos.Fields.Item("description"

The solution:
<%='Replace(rsPhotos.Fields.Item("description"


Duh.