PDA

View Full Version : write html tags from an xml file


meaculpa1113
08-13-2003, 10:20 AM
Hi,

I will describe my problem first, and then a solution that i have in mind. pls let me know i) if my solution is viable at all ii) and comments/suggestions on other types of solutions.

PROBLEM: I need to make a stand alone CD(web independent). The CD has a bunch of HTML documents in it that will primarily be used for printing by the people who will be receiving the CD. The content on the documents is the same for everybody. But each person who gets a CD wants to have their name, address, phone #, and a couple of other lines of personal information populated on top of each document. Now, there are around a hundred of these forms, and this information should by dynamic in the sense that they could change it later in they wanted to, and it should still appear on the forms.

MY SOLUTION: This is the solution I had in mind. I would have an 'options' window which would display an HTML form, that would collect all the information that needs to be put on each of the documents. If there is some way in which I could write out this information into an XML file, and store it there on the users computer. (Assume that all the contents of the CD will be on the hard drive, and the CD wont be needed everytime to use any of the features, however utilizing the Internet is NOT an option).
So I thought that if that could be done, I could make a template for all the documents whcih would query that XML file for the name, phone number, and other such information and pre0populate it.

So my questions being:

i) How do I write a HTML form that would send the data to a file, without using CGI or anything like that which would be server dependent.
ii) How do I write code in my HTML form that would read tags from a certain file with a particular filename in a particular directory?

If you have a better suggestion to tackle the problem, feel free to comment on that. I have on such 'ego' that would forbid me from accepting that I am completely wrong!


ps. I have had quite some experience w/HTML, but am a newbie in XML.

Thank you for your help!

meaculpa1113
08-14-2003, 03:10 PM
somebody please reply..!!!!!!!!!

really need to get this done sometime soon..!!!

help is much appreciated..

thank you..!!

scoutt
08-14-2003, 06:28 PM
well for one you posted in the wrong forum. what you want is a little difficult. html alone cannot access the users hard drive, even for XML. here is a suggestion.


it maybe possible to write it in php and then save a text file on the users hard drive and then get php to read this file when ever they open it. this will work but you need some other stuff on this cd as well. you will need a server adn php executable. this has been discussed before on this forum so have a search. if you cannot fin dit I will find the site that you will need.

Jon Hanlon
08-14-2003, 08:03 PM
If the only browser used is IE5+, then you can store data in a userData store. These stores can hold up to 64k per page.

See http://msdn.microsoft.com/workshop/author/persistence/overview.asp

Here's a little sample for you:

<html>
<head>
<title>Userdata</title>

<style type="text/css">
.userData { behavior:url(#default#userdata); }
</style>

</head>
<body>

Instructions: Click inside the black box and enter some new text.<br>
Save this data with the <i>Put Data</i> button.<br>
Then reload, close down IE, reboot, whatever. Return to this page.
Restore the saved data with the <i>Get Data</i> button.
<br><br>

<span class="userData" style="border: thin solid black"
contenteditable="true" id="spnUserData">
What's new pussycat?
</span>

<br><br>
<button
onclick='putUserData(spnUserData,"myData","myText",spnUserData.innerText)'
id='btnPut'><i>Put Data</i></button>
<br>
<button
onclick='spnUserData.innerText=getUserData(spnUserData,"myData","myText")'
id='btnGet'><i>Get Data</i></button>

<script language="javascript">
function putUserData(oUD,sUDName,sName,sVal) {
oUD.setAttribute(sName,sVal);
oUD.save(sUDName);
return;
}

function getUserData(oUD,sUDName,sName) {
oUD.load(sUDName);
return oUD.getAttribute(sName);
}
</script>

</body>
</html>

agent002
08-15-2003, 04:17 AM
That's cool, Jon. I have never known about any such thing.

meaculpa1113
08-15-2003, 10:51 AM
Jon.. ur suggestion does sound impressive.. and i checked it out.. it also works nicely..

but.. if i cud just tweak it a bit, it wud be optimal. wat this code is doing that, it takes the data and storing it somewhere and it cud be retrieved by clicking a button. but how to get it to be dynamically loaded in different documents?

not even sure, if it cud b tweaked that much.. but if u have any other ideas plesae lemme know! ( i really dont wanna have to go down to java for odin somethin this simple!)

Jon Hanlon
08-16-2003, 12:17 AM
Well I thought you'd get the users to fill in their own details. I'm not sure what you want.
Do you want the users to enter their details? Or have it on the CD? If it's on the CD then it's not changeable.

If you want the data loaded in the documents, just add an onload() handler to get the userData from the store and pop it into the HTML.