SunQuest
           XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old November 4th, 2003, 10:48 AM
Flat Eric Flat Eric is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 2 Flat Eric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
variable use in image links to documents..

I have to link to a certain document. The name of the document should be grabbed from a xml file. For example, <a href="document12.pdf">Here is a link</a> with number 12 in a variable..

Also "Here is a link" should be a rollover image (a button), and not just a text. So there's the well-known rollover script in there too..

I tried this:

<script type="text/javascript">var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false";
xmlDoc.load("myfile.xml");
P=xmlDoc.documentElement.childNodes;
document.write( "<a href='document"+ P.item(0).text + ".pdf' onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgdoc','','imgdocover.gif',1)"><img name="imgdoc" border="0" src="imgdoc.gif" width="149" height="50"></a>" );
</script>

But I get an error: ") expected" in the document.write line
The syntax is similar to an "img src" line (which works fine), so the variable and the xml is ok, just that it seems that it doesn't apply to "a href"..
I don't know if this is the way to do it, so please help..

Thank you.

Reply With Quote
  #2  
Old November 4th, 2003, 04:01 PM
teedee teedee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 teedee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
It's a Javascript thing, you forgot to put a backslash before the quotes in the document.write ("...") statement
Code:
<script type="text/javascript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false; 
xmlDoc.load("myfile.xml"); 
P=xmlDoc.documentElement.childNodes(); 
document.write( "<a href=\"document"+ P.item(0).text + ".pdf\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('imgdoc','','imgdocover.gif',1)\"><img name=\"imgdoc\" border=\"0\" src=\"imgdoc.gif\" width=\"149\" height=\"50\"></a>" ); 
</script>  

Reply With Quote
  #3  
Old November 5th, 2003, 09:35 AM
Flat Eric Flat Eric is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 2 Flat Eric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

Thanks a lot!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > variable use in image links to documents..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway