0

I have 3 dropdowns. Only when Australia is selected from the country dropdown, I have to show a help hyperlink for the city dropdown. The user can read some guidelines when he selects Australia before he can select a city. For this I want to append the 'City' label with an a href. How can I achieve this? I tried the following but failed:

function ddCountryChange() 
 {
     var ddCountry = document.getElementById("ddCountry");
     var tbCity = document.getElementById("tbCity ");
     if (ddCountry.value == "AUS"){               
            tbCity.innerHTML = '<div class="GXIRowTitle"><a href="/City-Search.ashx" target="_blank" style="color:blue">[<u>Help</u>]</a>&nbsp;<span style="font-weight:normal;">City : &nbsp;&nbsp;</span></div><div class="GXIRowControl"><div id="ctl02_ctl00_GXDivLeft_TbCity_TbBoxReadOnly" style="display: none;">&nbsp;</div><span id="ctl02_ctl00_GXDivLeft_TbCity_TbBoxNonReadOnly" style="display: inline;"><input name="ctl02$ctl00$GXDivLeft$TbCity$TbBox" type="text" maxlength="64" id="ctl02_ctl00_GXDivLeft_TbCity_TbBox" autocomplete="off"><ul id="ctl02_ctl00_AcCity_completionListElem" class="GXAutoComplete_CompletionListElement" style="position: absolute;"></ul></span><input type="image" name="ctl02$ctl00$GXDivLeft$TbCity$Btn" id="ctl02_ctl00_GXDivLeft_TbCity_Btn" align="ABSMIDDLE" src="/ucommand/CRM/images/icn/DropDown.gif" alt="Show List" onclick="javascript:onAutoCompleteViewList("ctl02_ctl00_AcCity");return false;" style="border-width:0px;"></div>';
        }
 }

While debugging through Firebug, I see that the city label is appended with a 'Help', but once the process finishes, the 'Help' disappears.

3
  • 2
    Its not clear what your specifically trying to do or what issues you are having with your attempt
    – rdans
    Apr 16, 2015 at 15:28
  • Unrelated: in your onclick attribute, don't start it with javascript: - the attribute value is already javascript.
    – Joe Enos
    Apr 16, 2015 at 15:46
  • What type of element is tbCity? Is it a <table/>, <select/>, <label/>, or something else? It would really help our understanding if you simply showed the associated HTML markup.
    – Brett
    Apr 16, 2015 at 16:12

1 Answer 1

0

Assuming ddCountry is the select element

 // Detect when value is changed
ddCountry.addEventListener("change", function(e){

  // Is its value now "AUS"?
  if(this.value == "AUS"){
      // Do stuff such as appending whatever label
  }else{
      // Hide stuff again?
  }

});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.