Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Multiple DB Field Instances On One Page

Posted 23 Jul 2002 20:33:09
1
has voted
23 Jul 2002 20:33:09 Jeremy Conn posted:
I need to use multiple instances of a DB field for an image selector thing I am creating, but am having a problem. It seems as if by default UD will only let me use one instance of a DB field on a page.

<b>EXAMPLE:</b>
Here is the DB instance I am using...
<font color=green>&lt;%=(rsUploads1.Fields.Item("Image_Path".Value)%&gt;</font id=green>
...which works fine used once.

But, if I want to use it twice for this JavaScript thing I am trying to do below...
<font color=red>&lt;span onClick="ImageName('&lt;%=(rsUploads1.Fields.Item("Image_Path".Value)%&gt;')"&gt;</font id=red><font color=green>&lt;a href="javascript:void(0);"&gt;&lt;img src="&lt;%=(rsUploads1.Fields.Item("Image_Path".Value)%&gt;" border="1" align="middle" onClick="self.close()"&gt;</font id=green>
...then only one of them shows up.
<b>END EXAMPLE</b>

Is there a protocol for using an instance twice on a page?


(DWMX|IIS5|WXP|ASP/VB)
*Connman21*
www.conncreativemedia.com

Replies

Replied 23 Jul 2002 23:13:57
23 Jul 2002 23:13:57 Owen Eastwick replied:
Hi Connman,

If you are using a recordset field multiple times on a page you should store it in a variable first. It's more efficient and the page should load quicker. e.g.

&lt;% varImagePath = rsUploads1.Fields.Item("Image_Path".Value %&gt;
&lt;span onClick="ImageName('&lt;%= varImagePath %&gt;')"&gt;&lt;a href="javascript:void(0);"&gt;&lt;img src="&lt;%= varImagePath %&gt;" border="1" align="middle" onClick="self.close()"&gt;

However, not doing it wouldn't stop a page working, it's purely an efficiency thing. I'm not exactly sure why your code isn't working, I would be inclined to be more suspicious of the JavaScript. Have you tested it using a real image path rather than one from a database field.



Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 23 Jul 2002 23:45:02
23 Jul 2002 23:45:02 Jeremy Conn replied:
See www.howtoultradev.com for thread...

(DWMX|IIS5|WXP|ASP/VB)
*Connman21*
www.conncreativemedia.com
Replied 24 Jul 2002 01:16:56
24 Jul 2002 01:16:56 aegis kleais replied:
trust oeastwick on this connman21. I had the EXACT same problem. Place the database value into a variable and BAM, you can use it as many times as you want. I'll be getting DMX (actually, Studio MX) soon and I hope just for the fudge of it that I don't have to place everything into a variable all the time <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 24 Jul 2002 01:39:56
24 Jul 2002 01:39:56 Jeremy Conn replied:
How would I place that into a variable?

(DWMX|IIS5|WXP|ASP/VB)
*Connman21*
www.conncreativemedia.com
Replied 24 Jul 2002 01:43:16
24 Jul 2002 01:43:16 aegis kleais replied:
Up in the ASP code:

&lt;%
variableName = recordsetName.Field.Item("fldFieldName".Value
%&gt;

Then in your page code:

You son of a &lt;%= variableName %&gt;. Yeah! You heard me! I called you a son of a &lt;%= variableName %&gt;

Of course, your choice of words is optional and all.

Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])

Reply to this topic