0

would it be possible to type in pure HTML into a textarea and then add that html to a different html document?

I am thinking this could work? or maybe jquery with ajax might work?

<form action="HTML.html" method="post">
    <textarea rows="7" cols="30"></textarea>
    <button type="submit">send</button>
</form>

but I'm not sure, also I know I can do it with PHP but I wanna try and see if it would be possible through just javascript.

4
  • You're going to have to be more explicit about exactly what you want to do with it if you want a good answer. Commented Jun 28, 2011 at 4:23
  • i want to create a blog type thing(like wordpress) but with just javascript instead of needing PHP. Commented Jun 28, 2011 at 4:25
  • Javascript is client side, PHP (and your database) are server side. Client side can't talk to server side without an intermediary (AJAX would "talk" to the DB via php) so no, not possible. That being said, building a CMS is not a difficult task at all. Commented Jun 28, 2011 at 4:35
  • yeah but i dont have PHP access on my website. and im cheap(; so i dont wanna pay for it lol Commented Jun 28, 2011 at 4:36

3 Answers 3

2

Permanently? No, it cannot be done just with Javascript. You can't edit a file on the server without write access to the server, and since Javascript runs in the user's web browser, it does not have write access to your server.

Temporarily? Maybe. If all you want is for the form's results to show up on the page that comes after the user hits submit, that's more feasible. First, though, Javascript can't read POST data, so that's out. Instead, you'd need to use GET, and use Javascript to read the query string stored at document.location.search, then write the user's HTML to the innerHTML of an HTML element.

Sign up to request clarification or add additional context in comments.

1 Comment

ah okay then nevermind. i was thinking of how i could make a blog type thing(like wordpress) but no PHP. thank you though!
0

You would probably need a Database and a Dynamic web language.

Comments

0

You can do something like this:

index.html:

<form action="HTML.html" method="GET">
    <textarea rows="7" cols="30" name="text"></textarea>
    <button type="submit">send</button>
</form>

HTML.html:

<script type="text/javascript">
    window.onload = function () {
        document.write(window.location.search.split('=')[1]);
    };
</script>

5 Comments

abd what does the javascript do exactly?
It get the first GET parameter in URL and write it into your page. It's just for study purposes, you can't use it for a blog.
@user645607: it prints the output of the form on the next page after the user hits submit, but only that one time. So, pretty much the code for the temporary solution I gave, which we now know wasn't what you were looking for. If it were, though, this would be exactly it :)
AH okay! hmmm could i store it in a cookie? lol or could i use html5 web storage?? :o
@user645607: That would kinda work technically, but you would be the only one who could see your blog posts, since the actual post data would be stored on your computer, not the web server. So, no go :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.