javascript - How to get dropdown value into .php file -


i need selected dropdown value .php file, send mail file.

when select 1 of 6 options dropdown, want selected option included mail "subject" of email.

here html code

<span class="custom-dropdown big">     <select id="mounth" name="mounth">         <option value="default">-- domain name --</option>         <option value="value1" rel="icon-temperature">value1</option>         <option value="value2">value2</option>         <option value="value3">value3</option>         <option value="value4">value4</option>         <option value="value5">value5</option>         <option value="value6">value6</option>     </select>     <input type="hidden" id="changeme" name="changeme" /> </span> 

popup email form

<div class="modal fade" id="popup-moda">     <div class="modal-dialog">         <div class="modal-content">             <div class="modal-header">                 <button type="button" class="close" data-dismiss="modal" aria-label="close"><span id="spanhide" aria-hidden="true">&times;</span></button>                 <h4 class="modal-title">contact us</h4>             </div>             <form action="" method="post" name="form" id="forms">                 <div class="modal-body">                     <div id="domain" name="domain"></div>                     <input required id="name" name="name" placeholder="name" type="text">                     <input required id="email" name="email" placeholder="email" type="text">                     <textarea id="msg" name="msg" placeholder="message"></textarea>                 </div>                 <div class="modal-footer">                     <button type="button" class="btn btn-default" data-dismiss="modal">close</button>                     <button type="submit" class="btn btn-primary">send</button>                     <div id="success" style="color: blue;"></div>                 </div>             </form>         </div><!-- /.modal-content -->     </div><!-- /.modal-dialog --> </div><!-- /.modal --> 

here js code displays selected option, text before sending email.

$(document).ready(function(){  $('.popup').click(function(e){     e.preventdefault();     $('#domain').html('<b>' + $('#mounth').val() + '</b>');     $('#popup-moda').modal('show');         return false; }); }); 

my php file

<?php $name = $_post['name']; $email = $_post['email']; $msg = $_post['msg'];  $to = 'example@example.com'; $subject = 'new customer enquiry'; $msg = <<<email subject: $subject message: $msg from: $name email: $email email; $headers = 'from:' . $email;  if (filter_var($email, filter_validate_email)) {  mail($to, $subject, $msg, $headers);   mail.  echo "thank email! reply possible.";  } else { echo "invalid email, please provide correct email address."; }  ?> 

thank guys. input appreciated!

put select inside form selected value sent server along rest of form parameters.

<form action="" method="post" name="form" id="forms">     <!-- ... -->     <select id="mounth" name="mounth">         <!-- options -->     </select>     <!-- ... --> </form> 

then in php file:

$subject = $_post['mounth']; 

and use in subject.

edit:

then can add hidden input form name , add dropdown's value upon selection:

<form action="" method="post" name="form" id="forms">     <!-- form stuff -->     <input type="hidden" id="hiddenmounth" name="mounth" value="" /> </form> 

and listen select's onchange:

$('#mounth').on('change', function() {     $('#hiddenmounth').val($(this).val()); }); 

and in php:

$subject = $_post['mounth']; 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -