Finding the text value of a dropdownlist

Results 1 to 2 of 2

Thread: Finding the text value of a dropdownlist

  1. #1
    Join Date
    Dec 1969

    Default Finding the text value of a dropdownlist

    Is there a way to find the text value of a ddl in javascript?<BR><BR>On an OnChange event, if the text value is equal to "- Other -", I want certain fields to be enabled.<BR><BR>The code in the code behind is as follows:<BR>&#060;code&#062;<BR>ddlDispatchInfo.At tributes.Add("onChange", "EnableDispatchInfoOther();")<BR>&#060;/code&#062;<BR><BR>The code in my JavaScript file is as follows:<BR>&#060;code&#062;<BR>function EnableDispatchInfoOther(){<BR> if (document.forms(0).ddlDispatchInfo.value == "- Other -")<BR> {<BR> document.forms(0).txtDispatchInfoOther.disabled = false;<BR> document.forms(0).lblDispatchInfoOther.disabled = false;<BR> }<BR> else {<BR> document.forms(0).txtDispatchInfoOther.disabled = true;<BR> document.forms(0).lblDispatchInfoOther.disabled = true;<BR> }<BR>} <BR>&#060;/code&#062;<BR><BR>However, instead of checking the value above in the "if" statement, I want to check the value of the text item inside the ddl (value obviously comes up with the value associated with the ddl, and not the text value). <BR><BR>How can I do this?

  2. #2
    Join Date
    Dec 1969

    Default .text instead of .value

    function EnableDispatchInfoOther()<BR>{<BR> var frm = document.forms(0);<BR> frm.txtDispatchInfoOther.disabled <BR> = frm.lblDispatchInfoOther.disabled <BR> = ( frm.DispatchInfo.text == "- Other -");<BR><BR>}<BR><BR>But isn&#039;t your logic backwards??? You have it so that if "- Other -" is selected then those other two fields will be *disbled*.<BR><BR>If I&#039;m right, change the == above to !=<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts