Turn div’s into input and validate them in a form

Asked

Viewed 135 times

1

I have a div with the attribute contenteditable="true", which opens the text box so that we can write directly in the div, right, so far so good, just like, I wanted to use this div as an input in a form, I didn’t want to use the same input you know, but div doing this function, only it turns out that I can’t get the value of this div with the php post method.

<form action="post.php" method="post" enctype="multipart/form-data">
     <div contenteditable="true"></div>
     <input type="submit" />
</form>

I know I could do this with Jquery or JS, but I just wanted to know if I could do it directly with php, if anyone knows please. But if I don’t have how I’m going to do it with Jquery... Vllw

  • Face because you don’t do it using a <textarea> and not a div? Why do you need so much to be a div?

  • Why do I need the element to grow along with the text while it is typing, like facebook, when a publication is being made and is typing it grows, and with textarea appears the scroll bar, And I couldn’t get it to grow with jquery because I still don’t really understand about jquery’s height functions. Already with the div when it goes being typed it already grows along.

  • With textarea you can get this same behavior using overflow-y: scroll; overflow-x: hidden; and manipulating the element with js so that when it reaches all the visualisable content, it increases the size, here an example

1 answer

3

Like Answered by @Andrew Jackman in another question.

Only form Elements are posted back to the server.

Only form elements are sent to the server. That way, the best way for you to do what you want is to create a input of the kind hidden and through the javascript when it’s time to do the submit, take the text from the div and move to the input created.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.