> 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
Saurabh - 30 Sep 2006 08:07 GMT
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[i].getAttribute("NAME")+"</TH></TR>";
for(var j = 0; j <
ODoc.selectNodes("/ROOT/DIRECTORY")[i].childNodes.length; j++)
{
filename =
ODoc.selectNodes("/ROOT/DIRECTORY")[i].childNodes[j].text;
path = ODoc.childNodes[i].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;
}
Saurabh - 30 Sep 2006 08:09 GMT
for(var j = 0; j <
ODoc.selectNodes("/ROOT/DIRECTORY")[i].childNodes.length; j++)
{
filename =
ODoc.selectNodes("/ROOT/DIRECTORY")[i].childNodes[j].text;
path = ODoc.childNodes[i].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????