Way to Retrieve file through Web service???

S

Saurabh

How can i recevice a file from server through web service or any other
method with a javascript code at client side??? The file list is
displayed and on click of button that particular file assosiated with
that button should be retrieved to the client from server.
 
T

Tom Cole

Saurabh said:
How can i recevice a file from server through web service or any other
method with a javascript code at client side??? The file list is
displayed and on click of button that particular file assosiated with
that button should be retrieved to the client from server.

You say retrieved. I assume then that you mean to have the client
download the specified file from the server?

If so, then simply do one of the following:

1. Provide anchors with the files' URL as the href attribute, or
2. If you want a button to initiate download then there are two
options:
A. Create a form for each file with the file's URL set as the action
attribute, or
B. Create a button for each file with the following onclick handler:
<input type="button" value="File1"
onclick="document.location=file1_url;"/>
Simple replace File1 with the filename and file1_url with the file's
url.

If downloading the file was not your goal, please let us know.

HTH
 
S

Saurabh

function GetList()
{
var strHTML = "<TABLE align=center>";
var servicename="GetList";
var ReplyXML = XmlhttpCall(servicename);
var Oxml = new ActiveXObject("Microsoft.XMLDOM");
Oxml.loadXML(ReplyXML);
var ODoc = Oxml.documentElement;
var outerCount = ODoc.childNodes.length;
var filename="";
var path="";
for(var i = 0; i < outerCount; i++)
{
strHTML = strHTML + "<TR><TH
colspan='2'>"+ODoc.childNodes.getAttribute("NAME")+"</TH></TR>";
for(var j = 0; j <
ODoc.selectNodes("/ROOT/DIRECTORY").childNodes.length; j++)
{
filename =
ODoc.selectNodes("/ROOT/DIRECTORY").childNodes[j].text;
path = ODoc.childNodes.getAttribute("NAME")+"','"+filename;
strHTML += "<TR><TD>"+filename+"</TD>";
strHTML += "<TD><input type='button' value='Read' id=btn"+i+j;
strHTML += " style='FONT-WEIGHT: bold; COLOR: blue;
BORDER-TOP-STYLE: none; FONT-FAMILY: Arial; BORDER-RIGHT-STYLE: none;
BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; FONT-VARIANT:
small-caps; BORDER-BOTTOM-STYLE: none'";
strHTML += "title='Click to Read/Open document'
onclick=\"Read('"+path+"')\"></TD></TR>";
}
}
strHTML = strHTML + "</TABLE>";
displayHTML.innerHTML = strHTML;
}
 
S

Saurabh

for(var j = 0; j <
ODoc.selectNodes("/ROOT/DIRECTORY").childNodes.length; j++)
{
filename =
ODoc.selectNodes("/ROOT/DIRECTORY").childNodes[j].text;
path = ODoc.childNodes.getAttribute("NAME")+"','"+filename;
strHTML += "<TR><TD>"+filename+"</TD>";
strHTML += "<TD><input type='button' value='Read' id=btn"+i+j;
strHTML += " style='FONT-WEIGHT: bold; COLOR: blue;
BORDER-TOP-STYLE: none; FONT-FAMILY: Arial; BORDER-RIGHT-STYLE: none;
BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; FONT-VARIANT:
small-caps; BORDER-BOTTOM-STYLE: none'";
strHTML += "title='Click to Read/Open document'
onclick=\"Read('"+path+"')\"></TD></TR>";
}

this is how i am generating a dynamic HTML.
can you elaborate a more on file url????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top