I'm new to Java script.
I'm implementing some web pages.
Now, i have TextBox fileds (for users to enter server ip,username and password),upload file button and a Submit button .i want to call a Javascipt script function which takes the values from the textbox and saves it to a .txt file on server before clicking submit button.
Using java script I'm able to read values but when I'm trying to write values into a file, it is not working. When i searched in net i found solution with ActiveXObject which workes only in IE.But I'm looking for the solution which works in all browsers.
My environment supports only javascript and PHP.
Please help me..
<form id="addnew">
<input type="text" class="id">
<input type="text" class="content">
<input type="submit" value="Add">
</form>
<script>
jQuery(function($) {
$('#form_addjts').submit(function(){
writeToFile({
id: $(this).find('.id').val(),
content: $(this).find('.content').val()
});
return false;
});
function writeToFile(data){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.OpenTextFile("D:\\data.txt", 8);
fh.WriteLine(data.id + ',' + data.content);
fh.Close();
}
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With