greektranslator
greektranslator

Reputation: 481

Uncaught TypeError: Cannot read property 'undefined' of undefined at HTMLFormElement.onmouseover

I am using this snippet:

onmouseover="this.title=this.options[this.selectedIndex].title"

so that I can add title tags in dropdown menu text.

<form name="searchform" onmouseover="this.title=this.options[this.selectedIndex].title" onsubmit="return doSearch();" accept-charset="', $context['character_set'], '">
<input class="search_input" type="text" name="search" value="" />
<input class="search_button" type="submit" name="submit" value="" />
<select class="search_select" name="sengines" onchange="return saveOption();">
<option value="?action=search2;search=" title="Full forum search">Forum</option>

The error I get when I check with browser tools is

Uncaught TypeError: Cannot read property 'undefined' of undefined at HTMLFormElement.onmouseover 

Upvotes: 0

Views: 356

Answers (1)

Black Hole
Black Hole

Reputation: 1382

you need bind the function of the event listener in this case

<form name="searchform" onmouseover="function(this)" onsubmit="return doSearch();" accept-charset="', $context['character_set'], '">

the this means the current tag/element will passed by parameter of the event

 onmouseover="function(this)"

well you add the event in the element that you want, or acces to child like you do

this.options[this.selectedIndex].title

Upvotes: 0

Related Questions