-1

My code

<form action="" method="post">

    <div name="name" contentEditable="true">You Favorite Movie</div>
    <p name="Comment"  contentEditable="true">Your Comment</p>

<button>Submit</button>
<form>
Asif Iqbal
  • 1,132
  • 1
  • 10
  • 23
  • 1
    The thing about a good question is that there should be, at the very least, a question being asked. What's stopping you, what problems have you faced? Please consider refreshing your memory of the "*[ask]*" guidance. – David Thomas Aug 14 '22 at 14:15

1 Answers1

0

As far as I know, only <input> tags are sent in the form data. However, ou could use invisible <input> tags which have data copied into them, like this:

<form action="" method="post">
    <div id="name" contentEditable="true" onchange="copyToHidden('name', 'nameInput')">You Favorite Movie</div>
    <input type="hidden" name="name" id="nameInput">
    <p id="comment" contentEditable="true">Your Comment</p>
    <input type="hidden" name="Comment" id="commentInput" onchange="copyToHidden('comment', 'commentInput')">
    <button>Submit</button>
<form>

then have this JavaScript somewhere in a script tag

function copyToHidden(elementId, inputId) {
    document.getElementById(inputId).value = document.getElementById(elementId).textContent;
}
Michael M.
  • 10,486
  • 9
  • 18
  • 34