Answer the question
In order to leave comments, you need to log in
How to get text in select option?
How to get text in select option?
<form method = "post">
<div class="form-group">
<label for="countryName">Company type</label>
<select class="form-control" id="countryName" name="countryName">
<option value="1">Russia</option>
<option value="2">United States</option>
<option value="3">United Kingdom</option>
</select>
</div>
<button type="submit" name="companyRegister" class="btn btn-default">Register </button>
</form>
<?php
if(isset($_POST['companyRegister'])){
$countryName = $_POST['countryName'];
echo $countryName;
}
?>
Answer the question
In order to leave comments, you need to log in
take it via JS before sending the submit and put it in a hidden field
First, it is more correct to name not countryName, but countryId.
Secondly, your backend needs to know the id and name matches anyway. Additionally, this information does not need to be transmitted from the front.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question