RadhaKrishnaKiJaya
asked on
How to make a href dynamic
Hi Experts,
I have the following code.
Is it possible to make this href dynamic? An input hidden field "CultureLanguage" contains the language. If it is "En" then I want the URL to be "\join?lang=EN". Otherwise \join?lang=fr-CA.
I am using C# and MVC
Thanks in advance.
I have the following code.
<div>
<a href="\join?lang=fr-CA" id="btnReset">@T("Reset")</a>
<a id="btnApply">@T("Apply")</a>
</div>
Is it possible to make this href dynamic? An input hidden field "CultureLanguage" contains the language. If it is "En" then I want the URL to be "\join?lang=EN". Otherwise \join?lang=fr-CA.
I am using C# and MVC
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for trying to help me! I just modified your solution little bit and it is working.
<a href="" id="btnReset">@T("Reset")</a>
jQuery(document).ready(function () {
if (jQuery("html").attr("lang") == "fr-CA") {
jQuery("#btnReset").attr("href", "/join?lang=fr-CA");
else {
jQuery("#btnReset").attr("href", "/join");
}
)};
Everything you mentioned above is doable + this will all be done in Javascript, if you're trying to make your <div> change in realtime, without a server trip.
You'll load all your language abbreviations (very little memory required), then just update the link in the <div> using JQuery (for best cross browser support).