Javascript - onkeyup, onclick and onfocus events are not getting fired automatically through Javascript

StackOverflow https://stackoverflow.com/questions/20982062

Question

I am automating a external web application(I can't change the code of external web app). I am able to set the value to the text box programmatically, but onkeyup, onclick and onfocus events are not getting fired automatically. This is code of text box.

 <input type="text" style="WIDTH: 145px" onfocus="doComboFocus(this)" 
 onkeyup="doComboSearch(this);enableAccountSearchForm();" 
 onclick=javascript:resetAccountSearchForm(); size=30 
 name=selectedAccountsNarrowSearch />

I have also try this.

selectedAccountsNarrowSearch.fireEvent("onclick");

doesn't get any help.

Working with Internet Explorer - 8

Please help me to fix this issue.

Any help would be greatly appreciated. Thanks

Was it helpful?

Solution

Try putting the event attribute content in double quotes.

<input type="text" style="WIDTH: 145px" onfocus="doComboFocus(this)"   onkeyup="doComboSearch(this);enableAccountSearchForm();" onclick="resetAccountSearchForm();" size="30" name="selectedAccountsNarrowSearch" />

The 'javascript:' in the onclick attribute might also be causing a problem.

OTHER TIPS

You need to wrap your attribute in quotation marks (single or double).

<input type="text" style="WIDTH: 145px" onfocus="doComboFocus(this)"
 onkeyup="doComboSearch(this);enableAccountSearchForm();"
 onclick="javascript:resetAccountSearchForm();" size="30"
 name="selectedAccountsNarrowSearch" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top