0
<div class="member_management_area" style="display:none">
    <div class="member_search">
        <a class="member_search_zone">
            <span class="glyphicon glyphicon-menu-hamburger searchMenuyo" aria-hidden="true"></span>
            <span name="searchMenu" id="searchMenu">검색 유형을 선택하세요</span>
        </a>
        <input type="text" name="keyword">
            <a class="memberSearch_bt">
                <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
            </a>
            <select id="choiceSearchMenu" name="type" onchange="menuDisplay(this.form)">
                <option value="0"> ---- 선택하세요 ---- </option>
                <option value="1">아이디로 검색</option>
                <option value="2">끝 번호로 검색</option>     
            </select>
    </div>
</div>

$('.searchMenuyo').click(function()
{
    $('#choiceSearchMenu').slideDown(); 
});

$('#choiceSearchMenu').mouseout(function()
{
    $('#choiceSearchMenu').slideUp();
});

function menuDisplay(frm)
{
    var menu = frm.type.selectedIndex;
    console.log(menu);

    if(menu == 1)
    {
        document.getElementById('searchMenu').innerHTML('Search ID');
    }

    if(menu == 2)
    {
        document.getElementById('searchMenu').innerHTML('Search Last PhoneNumber');
    }
}

enter image description here

If you select the value of the select option from the slideDown menu, the value must be changed, but continue to var menu = frm.type.selectedIndex; In this part, Uncaught TypeError: Can not read property 'type' of null.

Why is this error happening and how can I fix it?

I would appreciate it if you could help me.

8
  • 1
    It means the variable frm is undefined. Meaning, that the function is not getting the form element when the function is called. Commented Aug 6, 2017 at 13:08
  • An error occurred because there was no form tag. So I added a form tag and I ran the project, but this time document.getElementById ('searchMenu'). InnerHTML ('Search ID'); In this passage, Uncaught TypeError: document.getElementById (...). InnerHTML is not a function. Why does this error occur? @NisargShah Commented Aug 6, 2017 at 13:17
  • 1
    That's because innerHTML is not a function. You can set it like this: document.getElementById('searchMenu').innerHTML = 'Search ID'; Commented Aug 6, 2017 at 13:22
  • 1
    Sure..You're welcome! Commented Aug 6, 2017 at 13:29
  • 1
    No probs, I will check and see if I could help in any way. :) Commented Aug 6, 2017 at 13:34

1 Answer 1

1

The error "Uncaught TypeError: Can not read property 'type' of null" means that the frm variable is undefined. Meaning, it isn't getting its value when the function is called during onchange event.

var menu = frm.type.selectedIndex;

Also, regarding your query about innerHTML, you could set its value like this:

document.getElementById('searchMenu').innerHTML = 'Search ID';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.