Let say that I have the form below:
<form action="sendMessage.php" method="post">
<label>Subject</label><input type="text"></input>
<label>Message</label><input type="text"></input>
<input type="submit"></input>
</form>
How can I send an another value like topic(which is pre-defined) without creating an another element for that? Is it possible or do I have to make input element and style it with display: none;
The answer can contain html, javascript or jquery code.
Yes, you can have a valid input without a form.
The method attribute specifies how to send form-data (the form-data is sent to the page specified in the action attribute). The form-data can be sent as URL variables (with method="get" ) or as HTTP post transaction (with method="post" ). Notes on GET: Appends form-data into the URL in name/value pairs.
No you don't. The form is used to send data to the server, like some kind of search mask to query a database. You can put all your input tags in one form tag.
Use a hidden input element:
<input type = "hidden" name = "topic" value = "something" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With