I have the following problem. I have a form where I can choose from three options. The problem is that it does not send the selected option while the other sections Name, surname, etc. send. Below I am sending the code: thank you in advance
<div class="col-sm-4">
<div class="dropdown">
<button class="btn btn-dropdown dropdown-toggle" type="button" id="service-type" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="drp-name" data-bind="label">Choose</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="service-type">
<li><a href="#">x1</a></li>
<li><a href="#">x2</a></li>
<li><a href="#">x3</a></li>
</ul>
</div>
</div>
php code:
<?php
$to = '[email protected]';
$subject = "Appointment Form";
$servicetype = stripslashes($_REQUEST['service-type']);
$msg = "";
$msg .= "Service Type: ".$servicetype."\r\n\n"; // add sender's sources to the message
$mail = @mail($to, $subject, $msg, "From:".$email);
if($mail) {
header("Location:index.html");
} else {
echo 'Message could not be sent!';
}
?>
I also added JS but it still does't work
Dropdown Select
$( document.body ).on( 'click', '.dropdown-menu li', function( event ) {
var $target = $( event.currentTarget );
$target.closest( '.dropdown' )
.find( '[data-bind="label"]' ).text( $target.text() )
.end()
.children( '.dropdown-toggle' ).dropdown( 'toggle' );
return false;
});
<select>tag?selectelement. You need to add some JavaScript to handle when a user selects something.)nameattribute. Also,buttons do not get transmitted unless they are clicked.