i am trying to set value in dropdown from query string but unable to do so , below is the code
private SelectReferralFromQueryString(name) {
name = this.GetParameterValues('Country');
if (name != false) {
name = decodeURIComponent(name);
//here name comes correct as Keith T. What should I do from here?
}
}
private GetParameterValues(param) {
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < url.length; i++) {
var urlparam = url[i].split('=');
if (urlparam[0] == param) {
return urlparam[1];
}
else
return false;
}
}
<Dropdown
placeholder="Select an option"
selectedKey={this.SelectReferralFromQueryString(name)}
label="TRAVELLING TO"
options={this.state.ddlCountry}
styles={dropdownStyles}
onChange={(_, optionSelected) => {this.DataBind(optionSelected.key,'TravelTo');
}}
/>