• Resolved Pierre_02

    (@pierre_02)


    Hi.

    Probalbly a stupid quesion but I was using:
    var input = document.getElementById('forminator-field-text-1');
    to auto-complete address with the API of Google maps but since the last update I don’t know how to target my field as the ID is constantly changing…

    TIA for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @pierre_02

    You’re right, something in the last update changed how the fields were IDed.
    Improvement: Form fields now have a unique ID. This unique ID is also added as data-uid attribute to the form tag, so If you currently have scripts that use field ID’s, these will need to be updated now
    And I’m guessing this is affecting your script.

    From my understanding, the field element will now have a “data-uid” attribute which you can use to target it.

    If you can share a link to a page with your form on it, I can investigate further.

    Update:
    I upgraded my Forminator to check it out.

    So field IDs are now appened with a unique identifier on every load of the form ex: forminator-field-text-1_63243a28588f0, and the 63243a28588f0 part changes on every load.

    One possible way to update your selector to target this would be:
    document.querySelector("[id^='forminator-field-text-1_']");

    This was accomplished using a CSS wildcard selector to account for the changing portion of the ID.

    Hope this helped!

    • This reply was modified 1 year, 7 months ago by Aakash.
    Plugin Support Pawel – WPMU DEV Support

    (@wpmudev-support9)

    Hello @pierre_02 !

    Apologies for the inconvenience caused by this!

    Indeed, we made a change to allow multiple forms to be present on the same page and not trigger alerts about HTML standards. Some users need this to be possible so we went ahead and added this improvement.

    Regarding the solution – it’s what @aakash8 said 🙂

    Warm regards,
    Pawel

    Hi @pierre_02,

    Here is my solution because of the last update :

    var dataUID = $('#forminator-module-${id}').attr("data-uid");
    var name = '#forminator-module-${id} #forminator-field-text-1_${dataUID}';
    

    Hope this will help you

    • This reply was modified 1 year, 7 months ago by padi1111.
    • This reply was modified 1 year, 7 months ago by padi1111.
    • This reply was modified 1 year, 7 months ago by padi1111.
    • This reply was modified 1 year, 7 months ago by padi1111.
    • This reply was modified 1 year, 7 months ago by padi1111.
    • This reply was modified 1 year, 7 months ago by padi1111.
    Thread Starter Pierre_02

    (@pierre_02)

    Hi

    Thanks all for your help :)!

    I have replace my code by:
    var input = document.querySelector("#text-1 input");
    And now everything is working fine.

    For my part as I really like (love) CSS, i’m really not sure that the last update is a true improvement for targeting our fields.

    This is really not simple now to be able to easily target a tag. I hope that you’ll quickly give us a good solution to be able to easily customize our fields :).
    For the moment, I have to verify ALL the websites where I’ve customized the rendering, because i’m pretty sure that all my “settings” are no more applied…

    TIA.

    Plugin Support Pawel – WPMU DEV Support

    (@wpmudev-support9)

    Hello @pierre_02 !

    Glad to hear it’s working now and apologies for the inconvenience caused by the changes!

    I’ll share your feedback with the Forminator team so they can review it further 🙂

    Kind regards,
    Pawel

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with document.getElementById with the last update’ is closed to new replies.