How to get value from and send it through php? It's okay with text input but I can't get value. I just need to send values through email via ajax and php.
html code
<div class="input">
<input type="text" name="height" placeholder=""/>
</div>
<div class="input">
<select name="select">
<option value="1">one</option>
<option value="2">two</option>
</select>
</div>
<div class="input">
<select name="selectt">
<option value="3">three</option>
<option value="4">four</option>
</select>
js code
var user_height = $(this).find("input[name='height']").val();
var user_select = $(this).find("input[name='select']").val();
var user_selectt = $(this).find("input[name='selectt']").val();
var ok_send = $(this).find('.results_send_form');
//getting values
$.ajax({
url: "send.php",
type: "post",
dataType: "json",
data: {
"height": user_height,
"select": user_select,
"selectt": user_selectt,
}
Replace your code
var user_height = $(this).find("input[name='height']").val();
var user_select = $(this).find("input[name='select']").val();
var user_selectt = $(this).find("input[name='selectt']").val();
to
var user_height = $(this).find("input[name='height']:selected").val();
var user_select = $(this).find("input[name='select']:selected").val();
var user_selectt = $(this).find("input[name='selectt']:selected").val();
You don't have an input named select
or selectt
, these are select menus. I don't know what this
refers to in your code since you didn't include the context, but you would need to use select[name='select']
or select[name='selectt']
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.