1

I'm trying to access the pre-filled values during the Magento onepage checkout (index.php/checkout/onepage/). Magento pre-fills the address if you select the "Shipping Address" to be the same as the "Billing Address" but later return one step back to edit the "Shipping Address" manually.

I'm having trouble to find the pre-filled values in the entire DOM. It's not possible to access the value with JavaScript what so ever.

Here's how I'm currently trying it:

document.getElementById('shipping:city').val

The DOM element looks like the following (no trace of the actual value):

<div class="input-field">
    <input type="text" title="Stadt" name="shipping[city]" class="input-text  required-entry" id="shipping:city" onchange="shipping.setSameAsBilling(false);">
    <label for="shipping:city" class="required">Stadt</label>
</div>

How can I actually access those values using JavaScript?

1 Answer 1

2

You can access the value from native javascript using el.value. See below:

document.getElementById("shipping\:city").value
2
  • 1
    Any specific reason you put a backslash before the :? Commented Nov 28, 2017 at 17:10
  • if you are using native javascript document.getelement..., you can ignore the backlash. jQuery requires backslash to get the dom element.
    – Ner
    Commented Nov 29, 2017 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.