how to insert images using javascript

Author Message

Balaji Ramachandran

Wednesday 09 June 2004 9:02:23 am

Actually iam new to ezpublish and i have recieved a website to convert that site using eZPublish and they have used javascript to display the images in loop . but when i use the genral coding to display the image it is not working .please help me to proceed.
iam having the javscript coding like this .using this how to display images.

coding (javascript):

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
{literal}

function fnBuildTopMenu(cIn)
{
var myImg="/images/";
var cTemp = "";
cTemp = cTemp + "<TD><IMG SRC=" + myImg +"_03.jpg WIDTH=155 HEIGHT=107></TD>";
cTemp = cTemp + "<TD><IMG SRC=" + myImg +"_04.jpg WIDTH=155 HEIGHT=107></TD>";
cTemp = cTemp + "<TD><IMG SRC=" + myImg + "_05.jpg WIDTH=154 HEIGHT=107></TD>";
cTemp = cTemp + "<TD><IMG SRC=" + myImg + "_06.jpg WIDTH=155 HEIGHT=107></TD>";

}

my main problem is that variable myImg="/images/",they have decalred it once and called many times by + myImg +_03.jpg etc..,but i have transfered all the images in design/news/images. so how use the ezPublish coding for this to display the image.Please help me to proceed.

Paul Forsyth

Wednesday 09 June 2004 10:00:43 am

I see you are using literals. You need to use the 'literal' tag more often, for example:

 cTemp = cTemp + "<TD><IMG SRC=" {/literal}{myImg_03.jpg|ezimage}{literal} WIDTH=155 HEIGHT=107></TD>";

I hope you see what im doing here.

paul

--
http://www.visionwt.com

Ekkehard Dörre

Wednesday 09 June 2004 12:01:46 pm

More info:
http://ez.no/ez_publish/documentation/customization/tips_tricks/javascript_in_templates

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Trond Åge Kvalø

Thursday 10 June 2004 1:29:56 am

Hi Balaji!

As you say the myImg variable is "/images/". I therefore presume that the images are called _03.jpg, _04.jpg and so on, right?

Then you would use Paul's method and write:

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
{literal}

function fnBuildTopMenu(cIn)
{
var myImg="/images/";
var cTemp = "";
cTemp = cTemp + "<TD><IMG SRC="{/literal} {_03.jpg|ezimage} {literal}WIDTH=155 HEIGHT=107></TD>";
cTemp = cTemp + "<TD><IMG SRC="{/literal} {_04.jpg|ezimage} {literal}WIDTH=155 HEIGHT=107></TD>";

and so on.

Paul's post had a minor glitch since he used myImg_03.jpg instead of _03.jpg

Hope this helps
trondåge

trondåge

Paul Forsyth

Thursday 10 June 2004 1:37:27 am

Yip, thanks :) My bad cut and paste.

paul

--
http://www.visionwt.com

Jorn smith

Monday 01 December 2008 6:39:20 pm

when i search "insert images using javascript", i came here, but my question is how to put a image above another one with js and css. tks

http://www.sales-battery.com

zillion liu

Tuesday 10 February 2009 8:20:42 pm

The "{literal}" is a function library?
please tell me how to use it.

-------------------------------------------------
http://www.canon-digital-camera-battery.co.uk/batteries/canon-bp-511.htm

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 08:10:56
Script start
Timing: Jan 31 2025 08:10:56
Module start 'layout'
Timing: Jan 31 2025 08:10:56
Module start 'content'
Timing: Jan 31 2025 08:10:56
Module end 'content'
Timing: Jan 31 2025 08:10:56
Script end

Main resources:

Total runtime0.0137 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.2344151.2109
Module start 'layout' 0.00520.0024 739.445336.6484
Module start 'content' 0.00760.0047 776.093898.2813
Module end 'content' 0.01230.0014 874.375037.9922
Script end 0.0137  912.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002216.0952140.0002
Check MTime0.00117.8783140.0001
Mysql Total
Database connection0.00107.091910.0010
Mysqli_queries0.002417.119530.0008
Looping result0.00000.093710.0000
Template Total0.00117.810.0011
Template load0.00086.093610.0008
Template processing0.00021.703110.0002
Override
Cache load0.00053.991310.0005
General
dbfile0.00118.017280.0001
String conversion0.00000.050340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs