• Resolved asilentnaberbrane

    (@asilentnaberbrane)


    Hello, I’m using a jquery function to capture a value from the URL and then insert it into the form’s phone field. When I use it, I can actually populate the field, but for some reason, as soon as I click on the field, the value disappears. And more, when I submit the reservation, it records the value in another key, the same key as the URL (site.com/?key=274981279487). Can you help me? The function I use is this:

    function autopopulate_field() {
    ?>
    <script> 
    jQuery(document).ready(function($) {
    var param = new URLSearchParams(window.location.search);
    var value = param.get("param");
    if (value) {
    value = decodeURIComponent(value);
    value = atob(value);
    var intervalId = setInterval(function() {
    if ($("input[name='phone']").length) {
    $("input[name='phone']").val(value);
    clearInterval(intervalId);
    }
    }, 500);
    }
    });
    <script>
    <?php 
    } 
    add_action('wp_footer', 'autopopulate_field');

    But I am willing to any other means as long as I can enter the URL data

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter asilentnaberbrane

    (@asilentnaberbrane)

    I found out that it stores the value in the URL parameter array. So it doesn’t really work. If anyone has any suggestions I would appreciate it

    Thread Starter asilentnaberbrane

    (@asilentnaberbrane)

    function autopopulate_field() {
    
        ?>
    
        <script>    
    
        var phoneValue = '';
    
        jQuery(document).ready(function($) {
    
            var param = new URLSearchParams(window.location.search);
    
            var value = param.get("param");
    
            if (value) {
    
                value = decodeURIComponent(value);
    
                value = atob(value);
    
                phoneValue = value;
    
                var intervalId = setInterval(function() {
    
                    if ($("input[name='phone']").length) {
    
                        $("input[name='phone']").val(phoneValue);
    
                        clearInterval(intervalId);
    
                    }
    
                }, 500);
    
            }
    
        });
    
        <script>
    
        <?php
    
    }
    
    add_action('wp_footer', 'autopopulate_field');
    Plugin Author ameliabooking

    (@ameliabooking)

    Hello, thank you for reaching out to us.

    Unfortunately, this is currently not possible with the plugin’s built-in features, but our developers will work on implementing it in the future.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘autofill field’ is closed to new replies.