简体   繁体   中英

Javascript issue- Cannot Submit form after document.getElementById

document.getElementById("hs-search-origin").value = myloc;

I am successfully writing the value in a Text Box

The text box is attached to a searchbox and up on clicking the search button, search is not happening. I have to edit the textbox, like remove character or add character in the text box, to make it work.

For Ex:

myloc="i love stackoverflow";
document.getElementById("hs-search-origin").value = myloc;

The text box shows the value ie "i love stackoverflow" but on clicking the button, nothing happens.

I have to either edit the text in the textbox and then click on search to make it work. What is the issue, any guess

You have some code which runs (and does a search) when the user changes the value of the text box.

It doesn't run when you change the value with JavaScript.

You need to call that code explicitly when you want it to fire in response to something else than the user typing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM