-2

I have this thirs-part website, where if I select one country on the right

(as you can see in the video: https://i.gyazo.com/3a22aabb576f1e43040dae82204bb883.mp4 )

it changes shipping fees (in violet).

If instead, I use js ( from the chrome console for instance) to select one country using

 document.getElementById("order").value =  "IT";

it will select the country but the fees on the don't change. There is a way to let it works using javascript?

I have tried to also perform a click by

document.getElementById("order").click();

after selecting a value but it doesn't work.

7
  • You need to post more code. Please see stackoverflow.com/help/mcve Commented Sep 26, 2018 at 17:43
  • Please post a minimal reproducible example of your what you tried, as an edit to your question, and say specifically where you're stuck. Commented Sep 26, 2018 at 17:44
  • this is a third part websites i have tried with the cose i have posted but nothing . Commented Sep 26, 2018 at 17:47
  • 1
    Possible duplicate of How to change a <select> value from JavaScript Commented Sep 26, 2018 at 17:56
  • @MartinZeitler i think it's a different problem Commented Sep 26, 2018 at 18:25

1 Answer 1

0

Trigger the onchange after changing the value - you can do that from the console or from a chrome extension

document.getElementById("order").value = "IT";
document.getElementById("order").onchange();
<select id="order" onchange="alert(this.value)">
  <option value="">Please select</option>
  <option value="IT">Italy</option>
</select>

If the site has jQuery, use $("#order").val("IT").change()

Sign up to request clarification or add additional context in comments.

8 Comments

the website is third-par i can't edit the html part i just want to trigger the change when i use the getlelementbyyd.value="IT";
You can do that without changing the site. document.getElementById("order").value = "IT"; document.getElementById("order").onchange(); - the select has an onchange already
If the site has jQuery, use $("#order").val("IT").change()
i cannot use jquery unfrtunatly i have tryed whit the occhange() but the console gives me this error : Uncaught TypeError: document.getElementById(...).onchange is not a function at <anonymous>:1:50
if document.getElementById("order").value = "IT"; works then it is very strange that it does not allow onchange
|

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.