SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    enable - disable text field

    Hi, I'm having problems getting a script to work. When a certain option value is selected it is supposed to enable a text field. However, it's not working and I'm not sure why. Here's the code:
    javascript:
    Code:
    function checkProbSelect() {
            var probSelect = document.getElementById("helpFormProblemType");
            var otherSelect = document.getElementByID("otherProblemText");     
            if(probSelect.selectedIndex.value == "Other")
            {
                alert("selected other");
                alert(probSelect.value);         
                otherSelect.disabled = false;
                
            } else {               
                otherSelect.disabled = true;
            }    
        }
    markup:
    Code:
    <label for="${status.expression}">Problem Type: <span class="star">*</span></label>
                            <select name="${status.expression}" class="select_long" id="helpFormProblemType" onchange="checkProbSelect();">
                                <option value="">pick one</option>
                                <option value="Navigation" <c:if test="${status.value == 'Navigation'}"> selected="true"</c:if>>Navigation</option>
                                <option value="Printing" <c:if test="${status.value == 'Printing'}"> selected="true"</c:if>>Printing</option>
                                <option value="Advertising" <c:if test="${status.value == 'Advertising'}"> selected="true"</c:if>>Advertising</option>
                                <option value="Search" <c:if test="${status.value == 'Search'}"> selected="true"</c:if>>Search</option>
                                <option value="Registration" <c:if test="${status.value == 'Registration'}"> selected="true"</c:if>>Registration</option>
                                <option value="Performance" <c:if test="${status.value == 'Performance'}"> selected="true"</c:if>>Performance</option>
                                <option value="Other" <c:if test="${status.value == 'Other'}"> selected="true"</c:if> id="otherSelect">Other</option>
                            </select>
    
    <textarea name="otherProblemText" id="otherProblemText" class="textarea_longest_half" disabled="true">${status.value}</textarea>
    I'd appreciate any help that you can offer.

    Thanks,

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    probSelect.selectedIndex // This returns an integer between 0 and (length of list - 1).

    probSelect.selectedIndex.value // this very likely returns "undefined"

    Try
    probSelect.value // the value of the currently selected option

  3. #3
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks


Bookmarks

Posting Permissions

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