0

I have explored so many topics here but couldn't get answer yet. please help me to resolve my issue I have created an html generator with different functions which giving me result in a textarea box. I want to export the textarea value into html file

<html>

    <head>
        <script type='text/javascript'>
function output() {
  var lkpp = document['getElementsByName']('linkurl')[0]['value'];
  var tpwa = document['getElementsByName']('imgrlink')[0]['value'];
  var ttiwidget = document['getElementsByName']('widget.content')[0];
  ttiwidget['value'] = ''+lkpp+''+tpwa+''
};
        </script>
    </head>
    <body>
        <div>
             <table width="100%">
                        <tr>
                            <td width='40%'>
                                <label for='linkurl' >value1</label>
                            </td>
                            <td width='60%'>
                                <input type='text' name='linkurl' value='' size='40'>
                            </td>
                        </tr>
                        <tr>
                            <td width='40%'>
                                <label for='imgrlink' >Value2</label>
                            </td>
                            <td width='60%'>
                                <input type='text' name='imgrlink' value='' size='40'>
                            </td>
                        </tr>
                    </table>
<br>
            <input value='Generate' type='button' onclick='javascript:output();' />
<br>
<textarea name="widget.content" onfocus="this.select()" onmouseover="this.focus()" onclick="this.focus();this.select()" readonly='readonly'></textarea>
    </body>

</html>

I want to export/save the generated value into an HTML file. Check this is my file

  • 2
    This seems like a duplicate of many questions asked here already. Check out the answers on this question: http://stackoverflow.com/questions/21012580/is-it-possible-to-write-data-to-file-using-only-javascript – buzzsaw Nov 01 '15 at 22:24

1 Answers1

0

We need more info to give valid feedback. Precisely what is the roadblock?

Assuming the issue is getting the textarea content into a js variable: see this fiddle

You can get the value inside the Textarea with

document.getElementById('taGenerate').value;

After that, you can do whatever you want with it after that.

If you've made it that far, and your trouble is writing local fs: you will want to read this SO thread. Browser compatibility is going to be your biggest hurdle here.

Community
  • 1
  • 1
Kevin Ard
  • 594
  • 4
  • 12