HTMl text area - html

If we type something in the text area and press submit button, the values should be displayed on the same page under that. How to do that?
And make stay permanently on the page

You need javascript.
<form onsubmit="document.getElementById('output').innerHTML = document.getElementById('tarea1').value;return false">
<textarea id="tarea1"></textarea>
<input type="submit" />
</form>
<div id="output"></div>

You need some server side code, asp.net or PHP
Test for Post/Get parameters
Echo text in response
If you need to learn about forms and server side basics w3schools.com is the best place to start

In order to store something permanently, you need to have a server running your webpage. You can't just create an HTML file that can get changed on the fly and have those changes become permanent. You'll need to learn a server language (PHP for example) and have a server (like Apache) that can display your page.
Is this what you're intending? to make an actual site, not just a webpage?

Add a piece of JavaScript and attach it to onClick of the submit button. In the JavaScript, copy the value of the text area into the new place (assign the text to innerHTML) and also call submit() on the form.

Related

Using Perl to update HTML

I am having trouble wrapping my head around getting Perl to work with HTML. I am trying to do something I think is simple, but I cant find anything like it online.
Let's say I have a blank web page that has only a button labeled new, and when I press it, I want to destroy the button and create two new buttons, one that is a submit button, and one cancel that creates the old new button.
How would I go about doing that, without reloading the page?
From my understanding, the original HTML code would look something like this.
<form action="/cgi-bin/switchButtons.cgi" method="POST">
<input type="button" value="new">
</form>
and afterward should look like this.
<form action="/cgi-bin/switchButtons.cgi" method="POST">
<input type="submit" value="submit">
<input type="button" value="cancel">
</form>
On pressing cancel, it should refer back to the first snippet.
You can't do that.
/cgi-bin/switchButtons.cgi is a Perl program on the server. Clicking on one of the form's buttons sends a request message to the server, which runs switchButtons.cgi. The output from that program is the contents of a new web page which is sent back to the client (the browser). Of course that involves loading a new page
You could do it in JavaScript, which is part of the page and runs on the client. You can specify that a button will cause the browser to execute some JavaScript, which could alter the page 9n any way you want. But that doesn't answer your question

HTML website programming

I am starting a new business and am creating a basic website for displaying what it is about and its products.
I have started with an outline in HTML and CSS, but I have met on some trouble with adding submitting forms and adding a path to the links.
I have figured out how to make a basic form like this:
<form>
First name:<br>
<input type="text" name="firstname">
<br>
E-mail:<br>
<input type="text" name=„E-mail“>
</form>
But whenever I click the submit button the page gets an error and I am also not sure where the data would be stored. I have not yet set up the domain for the website so I am still doing this in my browser.
Also if I want to have a link to another page on my website such as:
Learn More
how do I add the path to the next page?
Thanks in advance!
You need to learn first how html works, and how to receive data with a server-side language (like php, java, asp, nodejs, etc).
To put a target to the form make something like this:
<form action="your-target-page.php" method="POST">
If you have a php server you can receive data:
$email = $_POST['email']
Learn more about form tag:
https://developer.mozilla.org/es/docs/Web/HTML/Elemento/form
Regarding the form you are going to need a server side language to handle the posting of a form. If you are new to website creation I would suggest using Wordpress and an already made free theme.
For your form this is better markup:
<form>
<label>First name:</label>
<input type="text" name="firstname">
<label>E-mail:</label>
<input type="text" name="email">
</form>
Assuming you have a file called learn_more.html in the same root that is how the link would work, target="_blank" opens it in a new browser window, if you just want it in the same window omit this.
Learn More
HTML form doesn't store any data with itself. It can just send a formed data to a server via HTTP protocol.
You need to have any kind of server side (CGI) program. Those are usually programmed in Perl, Python, Ruby, Java, PHP or so on.
In short
Send data to server side program from HTML form
Receive and process data with the program.

Post article with ckeditor

I am new in using ckeditor. I have installed ckeditor. In the editor, showed in my HTML page, i can write article there. But i don't know how to save it and show the article in my HTML page. here is my html code:
<form method="post">
<p>Editor:
<textarea class='ckeditor' id="ckeditor" name="ckeditor" row="10" cols="80">
</textarea>
<script type="/text/javascript">
CKEDITOR.replace('ckeditor');
</script>
</p>
<p>
<input type="submit">
</p>
</form>
You need to have a back-end of some sort. CKEditor works in the browser, so what you need to do is take that data, post it to your server and save it there. Your next step is to find out how what server side languages can you use - such as PHP. You need to learn how to build a system on your server that receives the data. There are various ways of doing this and they depend a lot on what kind of server you have.
Learn how to build a system with your server side language that receives POST and GET requests and saves them into a Database or a File. I recommend a Database, but that takes a little more learning I'm afraid.
You can get the data from CKEditor using JavaScript. Inside your form you need to add a small bit of JavaScript to update your textarea with the value of the editor. This is because CKEditor works by replacing the textarea with an iframe element - and thus the changes made in the iframe are not automatically applied to the textarea. You will need to learn how to attach a click event handler to your submit button and before submitting you need to run the following code that I copied from this other StackOverflow question.
for(var instanceName in CKEDITOR.instances) {
CKEDITOR.instances[instanceName].updateElement();
}
Good luck, have fun!

Retaining the input of a textarea when refreshing ASP Classic page.

I am trying to retain the users inputs in a textarea on my ASP classic form, so that if the recaptcha is entered wrong then the user's input is not lost and they only have to re-enter the captcha text. I am able to retain the input from a normal text box using value="<%=session("Address")%>". But the same thing does not work for textareas. I have seen a solution for PHP and so was hoping there was something available for ASP. How can i go about doing this, and if possible I would prefer to keep it server side? Thanks in advance.
like so:
<textarea name="" id=""><%=session("Address")%></textarea>
Keep in mind that you should not put out user generated texts directly in your site. think of malicious JavaScript code in session("address")...
you should encode those values like so:
<textarea name="" id=""><%=server.htmlencode(session("Address"))%></textarea>
same for all other places where you "inject" user generated values in your site...

Submit button in HTML forms

I'm trying to create a HTML form, and in the end I'm adding a submit button:
<submit submitLabel="Save"/>
Is there an attribute that can be configured so that when pressing the button not only saves the data in the form, but it redirects to another HTML form? Perhaps to create a workflow between HTML forms?
clicking a submit button inside a form issuing a POST/GET request to the page you defined in the <form action="_____"
you can put your second form in the other page (the page you defined in the action attribute)
or even better - you can use AJAX, and avoid reloading the page
There are some ways to do it, but it depends also with what language you work. HTML alone doesn't cut it. You need a server side language as well, such as ASP or PHP
When I use php, i simply create a form and make sure the action is marked to the next page. There i can put the next form in, but I can process also the information I just picked up.
See example below
<form method="post" action="the place of the next form plus where processing happens.php">
put here your fields
<button name="btn_moveon" type="submit" >Go further to next page</button>
</form>
Hope this helps.
You can do this through code or the ACTION attribute of the form tag.
No, there isn't such an element. You must do this on server side, with whatever programming language the server runs (eg. PHP, ASP, etc.).