Is there a way to use a non Form-Associated element as a natural associate?

Asked

Viewed 39 times

0

In the HTML, there are the elements 'Form-Associated', which are elements that are associated with form which are inside, like the input for example.

Good, but even if it’s unusual, if in a certain situation I want an element NAY 'Form-Associated' native were associated with the form in question, something like:

<form>
   <div value="VALOR"></div>
</form>

Is it possible to associate these elements only with HTML ? (submit the div value)

OBS: I don’t want to capture the value with JS or otherwise, the question is whether there is how to make these elements naturally associated with HTML.

1 answer

1


The answer is nay. Only form elements (input, textarea, select, button...) are received in the backend via form.

If it is strictly necessary to send an attribute value of a div in a submit (which is not correct, since the attribute value does not apply to divs but to form elements), you would have to make a control via JS creating a input hidden and sending the attribute value for such input before submitting, so that the backend may receive it.

Browser other questions tagged

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