0

I am trying to execute some Javascript in the console on Google Chrome at the checkout page of http://www.adidas.co.uk/.

Using the following to fill the input element with the below ID works fine as expected. $("#dwfrm_delivery_singleshipping_shippingAddress_addressFields_houseNumber").val("value here")

However, on different elements, as shown below, absolutely nothing happens and the text does not appear in the input field.

$("#dwfrm_delivery_singleshipping_shippingAddress_addressFields_firstName").val("value here")

You can see the page by adding a random item to the basket at http://www.adidas.co.uk/ and clicking "Checkout". I do not think providing HTML snippets would be helpful as I expect there to be something elsewhere on the page which is interfering.

I have tried setting the value by setting the value attribute directly, which also has the same effect of not updating the text input. Nevertheless, I am able to access my set values using jQuery's .val() method, just that for some input fields they do not display on the screen.

Why is this happening?

6
  • Did you delete your old question, make a new account and re-post it? Commented Jun 10, 2016 at 18:44
  • No not that I'm aware of? Commented Jun 10, 2016 at 18:45
  • This exact question was posted a couple hours ago and someone had answered it. I can't seem to find it though. Commented Jun 10, 2016 at 18:45
  • 1
    you have amnesia or what? how are you not aware of what you did a couple of hours ago? Commented Jun 10, 2016 at 18:47
  • 2
    @PootieTang "No not that I'm aware of?" wasn't me suggesting I have an inability to remember or a lack of awareness, but merely a pleonastic form of "No.". Commented Jun 10, 2016 at 19:46

2 Answers 2

1

@Emrah Izci Try running this:

Array.prototype.slice.call(document.getElementsByTagName("input")).forEach(function(elem, ind, arr) {elem.value = "TEST"});

I'm not sure what this means. Maybe there are hidden inputs that hold the actual value or something?

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

2 Comments

There were multiple DOM elements with the same ID, presumably dynamically added for some reason. Referring to the elements by class and setting the value on all of them solved my problem. Many thanks to you all on this wonderful day.
I'm glad I helped :)
0

You have changed the actual value of the input, but the shown value is not that, since it is angular driven HTML, angularJS controls what to display, yet does not takes console interference into account.

run after modification

$("element").trigger('input');

2 Comments

Thanks! This enabled me to find out about angularJS and its event handling. I edited your answer to include triggering the input event.
Actually, I mistook my testing - it actually doesn't work and it does not appear that the site uses angularjs.

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.