Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:42:14+00:00 2026-06-17T12:42:14+00:00

I am trying to create a HTML system, it creates a .txt form through

  • 0

I am trying to create a HTML system, it creates a .txt form through phonegap.

my HTML elements are as such

SCRIPT

function Savenote() {
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// Cordova is ready
//
function onDeviceReady() {
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}

function gotFS(fileSystem) {
    fileSystem.root.getFile("DCC.txt", {create: true, exclusive: false}, gotFileEntry, fail);
}

function gotFileEntry(fileEntry) {
    fileEntry.createWriter(gotFileWriter, fail);
}

function gotFileWriter(writer) {
    writer.onwriteend = function(evt) {
        console.log(" ' '");
        writer.truncate(11);  
        writer.onwriteend = function(evt) {
            console.log(" ' '");
            writer.seek(0);
            writer.write("Henry Aspden");
            writer.onwriteend = function(evt){
                console.log(" ' '");
            }
        };
    };
    writer.write("some sample text");
}

function fail(error) {
    console.log(error.code);
}
}
</script>

MY BODY/FORM

  <form>
<input type="text" style="width:100%" name="filename" placeholder="Enter File Name">
<textarea rows="10" style="width:100%" name="notes" placeholder="Enter Your Text Notes Here"></textarea>
</form>
<a href="#" onClick="Savenote()"><h1>SAVE</h1></a>

WHATS MY QUESTION THEN?
I need the values in my function to be taked from the form fields… and this is how if possible

Where it says

fileSystem.root.getFile("DCC.txt", {create: true, exclusive: false}, gotFileEntry, fail);
}

the “DCC.txt” section must be replaced by the field “filename” (i.e. “DCC.txt” is just for demo purposes). Also, the extension .txt is a constant, so it should be ‘filename’.txt if that make any sense?

Where it says

writer.write("Henry Aspden");

the “Henry Aspden” section must be replaced by the field “notes” (i.e. “Henry Aspden” is just for demo purposes)

EDIT NUMBER 1
Changed to

    function gotFS(fileSystem) {
    fileSystem.root.getFile("var filename = document.getElementById("filename");", {create: true, exclusive: false}, gotFileEntry, fail);
}

with

<input id="filename" type="text" style="width:100%" name="filename" placeholder="Enter File Name">

results in a syntax error here i think… how can I place this new variable within this existing function??

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:42:15+00:00Added an answer on June 17, 2026 at 12:42 pm

    Give the input elements an id:

    <input id="filename" 
        type="text" style="width:100%" name="filename" placeholder="Enter File Name">
    

    Then grab the element and save it as a JavaScript variable

    var filename = document.getElementById("filename").value;
    

    Put this somewhere before your function call, then pass the variable to your function:

    function gotFS(fileSystem) {
        var filename = document.getElementById("filename").value; //gets file name
    
        fileSystem.root.getFile( //call function 
            filename, {create: true, exclusive: false}, gotFileEntry, fail
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a PHP script that will create an HTML form
I am trying to create a multi/form-data Postback using System.Net.HttpWebRequests. Normally the browser creates
I'm trying to create a simple paypal purchase system. Going through a few tutorials,
I'm trying to create a copy/paste system for a HTML table using jQuery and
I am trying to create a html file out of a database, and I
I am trying to create a modular html document that employs smooth scrolling. If
I'm trying to create text in html, that once clicked, the the value of
I'm trying to create a small html fragment (a div element) consisted of three
I'm trying to create a custom HTML Helper to help simplify my masterpages menu,
I am trying to create some dynamic html out of some data from db.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.