I am new in jQuery and I am stuck in this situation:
I have a dropdown list:
<div class="gr">
<input type="hidden" id="Referral" name="Referral" data-required="required" value="">
<div class="fauxSelect">
<div class="arrow_btn">
<div class="arrow"></div>
</div>
<ul class="items" data-hidden-field="Referral">
<li class="item" data-value="Keith T">Keith</li>
<li class="item" data-value="Steve B">Steve</li>
</ul>
</div>
</div>
Now, the way custom javascript code works is that whatever you select in the dropdown will be in the hidden field: Referral (this part is already done via another JS library).
Everything works fine, if I am not passing any query string param. My question is: If I am passing the link with a parameter with Keith T in it, like this:
http://application.aspx?Referral=Keith T
I want Keith to be selected in my dropdown and my dropdown should get disabled. This is what I have so far in my jQuery:
SelectReferralFromQueryString();
function SelectReferralFromQueryString() {
var name = GetParameterValues('Referral');
if (name != false) {
name = decodeURIComponent(name);
//here name comes correct as Keith T. What should I do from here?
}
}
function 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;
}
}
Can someone guide me what should I do after I get the name value from Querystring?
and then call $("#mydropdown").prop("disabled", true)
– Anshul Nigam Jan 06 '15 at 03:32