samedi 28 février 2015

How do I find all input fields inside a form and copy their values into textarea using Javascript?

I want to add a couple of input fields (name, age, location, status, etc...) to my form.


When I click submit button, how do I get all the values inside a form and place them into a single textarea element, so that it's easy to copy? Thanks for the help!


My current code:



<form>
<input type="text" id="txt">
<button type="button" onclick="ShowText();">Submit</button>
</form>
<span id="show"></span>
<script>
function ShowText(){
var txt = document.getElementById('txt');
var show = document.getElementById('show');
show.innerHTML = txt.value;
}
</script>

Aucun commentaire:

Enregistrer un commentaire