Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: IMAGE DISPLAY >Thread Next - Re: IMAGE DISPLAY Re: IMAGE DISPLAYTo: NULL Date: 8/6/2007 10:01:00 PM
"Simon Gare" <simon@s...> wrote in message
news:Oh3tbhD2HHA.1168@T......
> Hi Anthony,
>
> thanks for the reply, the src is determined by the XML file as the image
is
> dynamic based on a selection which makes the src undeterminable in advance
I
> thought you could assign a dynamic value such as
>
> <img src="<%= bVehicle_type %>">
>
> but that didn't work. Are you trying to say that I need the spacer.gif
file
> in the src anyway but will be replaced by the XML value based on the image
> id?
>
> Or maybe if I Dim the aspect on the asp page itself that would work?
>
You seem to be confused about what happens on the client and what happens on
the server.
Things like this:-
<img src="<%= bVehicle_type %>">
is server side code in an asp file but this:-
document.getElementById("bVehicle_type").value = ...
is client side code running in the browser.
The answer to you question is yes unless you want an ugly "unknown image"
icon in you page you need to give your img a valid src to something
invisible. On your client with the XML loaded you can then assign the src
element. Like I said you need be careful that any relative url you assign
is appropriate to the pages BaseURL.
--
Anthony Jones - MVP ASP/ASP.NET
>
> "Anthony Jones" <Ant@y...> wrote in message
> news:eReqwF61HHA.5360@T......
> > "Simon Gare" <simon@s...> wrote in message
> > news:eAPCVfs1HHA.6128@T......
> >> Hi all,
> >>
> >> need to display an image from an url in an xml page but cant seem to
make
> > it
> >> happen, doesnt matter what i put in the image src=" it wont parse the
> >> url.
> >>
> >> The lines of code below are
> >>
> >> XML File
> >>
> >> <?xml version="1.0" encoding="ISO-8859-1" ?>
> >> - <guestbook>
> >> - <ROOT>
> >> <jID>27613</jID>
> >> <jVehicletype>images/SQLimages/VTypeStandard.gif</jVehicletype>
> >> <jDriverNo>8</jDriverNo>
> >> <jStatus>Select Status</jStatus>
> >> <jCustomerID>The Gare Group</jCustomerID>
> >> <jTimeOfBooking>21/07/2007 17:30:00</jTimeOfBooking>
> >> </ROOT>
> >>
> >> iIN THE JS FILE
> >>
> >> document.getElementById("bVehicle_type").value=
> >> xmlDoc.getElementsByTagName("jVehicletype")[0].childNodes[0].nodeValue;
> >>
> >> IN THE ASP PAGE
> >>
> >>
> >> <img src="<%= bVehicle_type%>" border="0">
> >>
> >> I know the above doesnt work but if someone could fill in the balnk I
> > would
> >> be grateful.
> >>
> >
> > I'm going to assume "bVehicle_type" is the intented ID of the img
element
> > which you are trying to assign a src value to.
> >
> > var img = document.getElementById("bVehicle_type")
> > var src = xmlDoc.selectSingleNode("/guestbool/ROOT/jVehicletype")
> >
> > if (src) img.src = '/' + src.firstChild.nodeValue
> >
> > The asp page would contain:-
> >
> > <img id="bVehicle_type" src="/images/spacer.gif" />
> >
> > where spacer.gif is a single pixel transparent gif.
> >
> > There is an assumption that the images folder is held at the root of the
> > site. If not you need to ensure the url supplied from the XML to the
src
> > attribute is correctly adjust to the base url of the page.
> >
> >
> >
> >
> >
> > --
> > Anthony Jones - MVP ASP/ASP.NET
> >
> >
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
