• Resolved sajadakbari

    (@sajadakbari)


    hi
    i want to fill input text value with javascript and send to database
    but when sent my form to database data is empty.
    how can i solved it

    my code:
    elementInput.value = ‘customeString’;

Viewing 4 replies - 1 through 4 (of 4 total)
  • Benjir Ahmed

    (@benjirahmed)

    Hey @sajadakbari ,

    Please check this code snippet. We have added a jQuery after_form_load hook for prefill values for user if needed.

    Regards

    Thread Starter sajadakbari

    (@sajadakbari)

    hey @benjirahmed
    i did it, but didn’t work

    Thread Starter sajadakbari

    (@sajadakbari)

    i added it to functions.php please check it:

    function metformy(){
    ?>
    <script>
    jQuery(‘#metform-wrap-dc2c9c7-19538’).on(‘metform/after_form_load’, function(e, data){
    console.log(‘s’);
    data[ ‘schoolname’ ] = localStorage.school_name; // data[ YOUR_INPUT_NAME ] = YOUR_INPUT_VALUE
    data[ ‘schoolcode’ ] = localStorage.school_code; // data[ YOUR_INPUT_NAME ] = YOUR_INPUT_VALUE
    data[ ‘managername’ ] = localStorage.manager_name; // data[ YOUR_INPUT_NAME ] = YOUR_INPUT_VALUE
    data[ ‘managermobile’ ] = localStorage.manager_mobile; // data[ YOUR_INPUT_NAME ] = YOUR_INPUT_VALUE
    return data;
    });
    </script>
    <?php
    }
    add_action(‘after_form_load’, ‘metformy’, 100);

    Benjir Ahmed

    (@benjirahmed)

    Hey @sajadakbari ,

    It seems you have added the code as wordpress hook and that will not work. Please add the code as normal script and hopefully the code will work. I have already informed you earlier that it is jQuery after form load hook.

    But after adding the code as script if it doesn’t work as expected please open a support ticket at our support center. We will help you to solve the problem.

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how can i change input value with javscript’ is closed to new replies.