jeudi 28 janvier 2016

display random text from a list on submit from textarea

I'd like to achieve the following:

I have a text area with an input ( Button type).

The user fill the text area, otherwise, on submit, the text which is being display ( in another div) should be different ( taken randomly from a list or other word ).

On the moment I have the following:

<div class="row">
    <div clas="col-md-12">
        <form name="myForm">
Content to be added:
<textarea name="myContent">ADD YOUR NAME</textarea>
<input type="button" value="Add content" onClick="addContent('result', document.myForm.myContent.value); setCookie('content', document.myForm.myContent.value, 7);">
</form>
</div>
</div>

<script>

function addContent(divName, content) {
     document.getElementById(divName).innerHTML = content;
}

</script>

which make appear the text added in the area in my other div. I have just no idea of the path I should take to display another text fro a specific list randomly instead.

Any highlight, will be amazing !

Thank you for your time




Aucun commentaire:

Enregistrer un commentaire