I’m trying to append the dropdown selection to the url.
This selection part
JavaScript
x
11
11
1
<div class="search2">
2
<span>Adults</span><select id="adult" class="dropdown-select" name="selectdropdown">
3
<option value="0">-</option>
4
<option value="1">1</option>
5
<option value="2">2</option>
6
<option value="3">3</option>
7
<option value="4">4</option>
8
9
</select>
10
</div>
11
Then the call sign
JavaScript
1
2
1
var Adult = $("#adult");
2
Final the append to url sign
JavaScript
1
2
1
url = url + "RedirectFromOutSide.aspx?arrivaldate=" + stringdata($("#StartDate").datepicker('getDate')) + "&departuredate=" + stringdata($("#EndDate").datepicker('getDate')) + "&hotelid=" + HotelID + "&Type=" + type + "&lang=" + Culture + "&adults=" + Adult;
2
But as the result comes &adults=object%...
instead of &adults=1
or 2
or 3
or 4
.
Advertisement
Answer
If you want to get the value:
JavaScript
1
2
1
$( "#adult").val();
2
However, if you want to get the selected text from drop-down:
JavaScript
1
2
1
$( "#adult option:selected" ).text();
2
Refer to this post: https://learn.jquery.com/using-jquery-core/faq/how-do-i-get-the-text-value-of-a-selected-option/