Hi!
can any one tell me how to read a content of a text file using Javascript and store it into form text box on form load?
here is the total html and js script which i have made:
i have a text file on the same folder where this html page is on webserver, i want the js will read the file take the data and put it into at here, on loading of the form:
<INPUT type="text" size=5 name="inrrate" value="">
any help will be highly appreciated.Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="Javascript"> function gotvalue(vt,rt) { form.hide.value=rt; return true; } function rates(form) { if (form.hide.value=="inr") { b=eval(form.inrrate.value) d=eval(form.inr.value) new1=d/(b/10) nn=Math.round(new1*Math.pow(10,3))/Math.pow(10,3) form.usdcr.value=nn } if (form.hide.value=="usd") { b=eval(form.inrrate.value) a=eval(form.usd.value) new2=(a*b*0.1) nn2=Math.round(new2*Math.pow(10,5))/Math.pow(10,5) form.inrcr.value=nn2 } } </script> </head> <body onLoad="javascript:this.form.inrrate.disabled=true;"> <FORM name="form" method="post"> <table border="0" cellpadding="5" cellspacing="0" bgcolor="#ffffff"> <TR> <TD width=510 colspan="3" class="tableup1" valign="top"> <b>Convert a USD amount given in Millions into a Rupee amount given in Crores or vice versa</b> <br></TD> </TR> <TR valign="top"> <TD width=175 height="59" nowrap>Enter USD amount here: <INPUT type="number" size=5 name="usd" value="" onchange="javascript:gotvalue(this.value,'usd');"></TD> <TD width=119 nowrap><div align="center">USD-INR rate: <INPUT type="text" size=5 name="inrrate" value=""> </div> </TD> <TD width=152 nowrap>Rupee Amt in Crores: <INPUT type="number" size=15 name="inrcr" value=""></TD> </TR> <TR valign="top"> <TD width=175 nowrap>Enter Rupee amount here: <INPUT type="number" size=5 name="inr" value="" onchange="javascript:gotvalue(this.value,'inr');"></TD> <td nowrap><div align="center"></div></td> <TD width=152 nowrap>USD amount in Millions: <INPUT type="number" size=15 name="usdcr" value=""> <INPUT type="hidden" size=15 name="hide" value=""> <br></TD></TR> <TR> <TD nowrap colspan="3"> <div align="left"> <INPUT type="button" value="Submit" name=action onclick="javascript:rates(this.form)"> <input type="reset" value="Reset" name=action onclick="javascript:clear(this.form)"> </div> </TD></TR> </TABLE> </FORM> </body> </html>
Thannks,



Reply With Quote

Bookmarks