Jump to content

Please Help Me Link From An Xml File?


kwarnaar27

Recommended Posts

Here's what I want to do:When a user starts to type in a document name into a text box, the autosuggest fills in the rest of the name of the document. This part already works no problem. Then, when the user clicks on the search button, I want the document to be loaded on the webpage. So far, I have been able to get a JavaScript popup to tell me which document I selected.The JavaScript code that I have is:

<script type="text/javascript">function disp_alert(){var txt=document.getElementById("document").valuealert("You selected "+ txt);}</script>

The above code works, and is pulling from my xml file, but it's just telling me what I put into the text box. I really want it to link to the document or page it's supposed to link to. The XML code that I have is:

<?xml version="1.0" encoding="UTF-8"?><documents>	<document id="1">		<name>Fax Form 1</name>	</document>		<document id="2">		<name>Fax Form 2</name>	</document>	<document id="3">		<name>Fax Form 3</name>	</document>	</documents>

Now, I know there should be code in my xml file to link to the forms, but I have been trying to figure that out but can't.Can anyone please help me? Thank you!

Link to comment
Share on other sites

Just place a URL to the form (or whatever else is needed to fetch the form), and change the window.location to that value (or make an XMLHttpRequest for it).I can't really suggest anything specific without more details to your specific situation.

Link to comment
Share on other sites

Just place a URL to the form (or whatever else is needed to fetch the form), and change the window.location to that value (or make an XMLHttpRequest for it).I can't really suggest anything specific without more details to your specific situation.
Thank you SO much for helping me out with this problem.Here is what's going on:
When a user types in a document name, the autosuggest fills in the text box with the available document names listed in my xml file (this works fine). Then they click the search button, which has a code like this:<INPUT id=myButton onclick=disp_alert() type=button value=select>So, the input code affects the JavaScript code I have which is this:<script language=JavaScript> <!--hide function disp_alert() { var txt=document.getElementById("document").valuewindow.open(txt); } //--> </SCRIPT>The 'txt' variable is opening up the element <name> from my xml which is this:<?xml version="1.0" encoding="UTF-8"?><documents>	<document id="1">		<name>Fax Form 1</name>		<name>http://www.webpage.com/faxform1.doc</name>	</document>		<document id="2">		<name>Fax Form 2</name>		<name>http://www.webpage.com/faxform2.doc</name>	</document>	<document id="3">		<name>Fax Form 3</name>		<name>http://www.webpage.com/faxform3.doc</name>	</document>	</documents>

So, what's happening is, when I put Fax Form 1 into the text box and hit search, a new window opens with a blank page like this:http://www.webpages.com/Fax Form 1So, the code is just repeating what's in the text box and not going to the form.However, when I put the direct link into the text box like this: http://www.webpage.com/faxform1.docThen that form opens up.What I really want it to do is have 'Fax Form 1' in the tex box and when you click search, the document http://www.webpage.com/faxform1.doc comes up on the page.I really hope I explained this clearly enough. I tried to help you help me the best I could.Thanks again.

Link to comment
Share on other sites

You're only repeating yourself... more details are needed, and you aren't giving any.A link to your page might be useful. That, or all of your (X)HTML, JavaScript and XML codes involved in this.

Link to comment
Share on other sites

You're only repeating yourself... more details are needed, and you aren't giving any.A link to your page might be useful. That, or all of your (X)HTML, JavaScript and XML codes involved in this.
My website needs a login and password to get in, so I'll just give you the code. I'll PM it to you.Thanks!
Link to comment
Share on other sites

My website needs a login and password to get in, so I'll just give you the code. I'll PM it to you.Thanks!
Thanks for trying to help boen_robot. If anyone out there could please help me with the coding problem it would be much appreciated. It's making JavaScript work with XML which is posing some problems. Here are my input button code and the script calling the name element from the XML document. All of my other XML and JavaScript are above.
<INPUT id=myButton onclick=disp_alert() type=button value=select><script type=text/javascript>	var theSuggest = new Spry.Widget.AutoSuggest("mySuggest","resultsDIV", "ds1","name");</SCRIPT>

I really need to get this to work soon, so if anyone has any ideas at all, I would really appreciate it.Thanks again!

Link to comment
Share on other sites

If you don't mind, I'll post out the whole code you PM-ed me. Hopefully, it would help someone help you:

<TABLE cellSpacing=0 cellPadding=0 border=0><script src="/SpryAutoSuggest.js" type=text/javascript></SCRIPT><script src="/xpath.js" type=text/javascript></SCRIPT><script src="/SpryData.js" type=text/javascript></SCRIPT><script src="/SpryDOMUtils.js" type=text/javascript></SCRIPT><script src="/unobtrusive_spry_data.js" type=text/javascript></SCRIPT><LINK href="/SpryAutoSuggest.css" type=text/css rel=stylesheet><script language=JavaScript> <!--hide function disp_alert() { var txt=document.getElementById("skill").valuewindow.open(txt); } //--> </SCRIPT><TBODY><TR><TD><DIV id=wrapper><H1>Spry AutoSuggest using XML Data</H1><script type=text/javascript>  var ds1 = new Spry.Data.XMLDataSet("/Canada/Upload/Images/Search/Test/skills.xml","skills/skill");</SCRIPT><FORM action="" method=get><P class=fieldHeading>Enter Document or Topic</P><DIV id=mySuggest><INPUT id=skill size=35 name=skill> <DIV class=.spryRegionDS1 id=resultsDIV><UL><LI class=sprySuggest id=spryRepeatDS1>{name}</LI></UL></DIV></DIV></FORM><P><INPUT id=myButton onclick=disp_alert() type=button value=select><script type=text/javascript>	var theSuggest = new Spry.Widget.AutoSuggest("mySuggest","resultsDIV", "ds1","name");</SCRIPT></P></DIV></TD></TR></TBODY></TABLE>

<?xml version="1.0" encoding="UTF-8" ?>  <skills> <skill id="1">  <name>http://www.webaddress.com/document_1.doc</name>   <name>Document 1</name>   </skill> <skill id="2">  <name>Document 2</name>   <name>http://www.webaddress.com/document_2.doc</name>   </skill></skills>

Link to comment
Share on other sites

  • 1 month later...

Hi All,I am new to all this. I am trying to link one xml file to another. Here's my code. It just dosent work.<!-- DEFINING XLINK NAMESPACE --><anydoc xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"> (anydoc is the root element containing dochead,sec*).<sec><head>Section Heading</head><p>Some text <it xlink:href="note.xml" xlink:show="new">Linking text</it>Rest of the text ....</p></sec>Although the file displays fine in the browser, the link does not work and while parsing the error "character ':' not allowed in attribute specification list" is shown in both these lines.Please help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...