• Resolved lotfus

    (@lotfus)


    Hello all,

    I am a newbie to wordpress. I want to integrate forms in my posts with a special requirement: at the form submission, I would like to know from which post the form was submitted.

    I have tried “Form Maker”, it is really great, but didn’t find an obvious way to get this post attributes. I have read a bit about other form plugins, but this feature is never mentioned.

    Any suggestion to solve this problem?

    Thanks a lot.

    https://www.ads-software.com/plugins/contact-form-maker/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter lotfus

    (@lotfus)

    Another way to see it is that I want to have feedbacks specific to the posts…

    Is there any way to do it?

    Plugin Contributor webdorado

    (@webdorado)

    Dear lotfus,

    Please create a hidden field on your form and name it, for example, Page Title. Afterwards go to Form Options > Custom Javascript and write the following code to before_submit() function:

    document.getElementsById('field_id').value =document.title;

    Please note, that you need to check the id of the hidden field and write it instead of field_id.

    Thank you.

    Thread Starter lotfus

    (@lotfus)

    Hello webdorado,

    thanks a lot for your answer.

    I did as you described: now I see indeed in my “submission” section the column pageTitle. The problem is that the piece of code is not working. The form doesn’t submit anymore when I hit the submit button (no reaction).

    Here is the code I inserted in before_submit():

    // before form submit
    function before_submit() {
         document.getElementsById('wdform_4_elementform_id_temp').value =document.title;
    }

    And I tried to put a simple string instead just to test, but it still didn’t work:

    document.getElementsById('wdform_4_elementform_id_temp').value ="Hello!";

    Any idea what is going wrong?

    Thanks a lot.
    L.

    Plugin Contributor webdorado

    (@webdorado)

    Dear lotfus,

    Please try writing the ID of your form instead of form_id_temp. For example, if your form’s ID is 5, the code will be:

    function before_submit() {
    document.getElementsById(‘wdform_4_element5’).value =document.title;
    }

    Thank you.

    Thread Starter lotfus

    (@lotfus)

    Hello again,

    thanks a lot for your help. I have just tried, unfortunately it doesn’t work. My form id is 12, here is my code now:

    // before form is load
    function before_load() {
    
    }
    
    // before form submit
    function before_submit() {
         //var pageName = "Hello!";
         document.getElementsById('wdform_4_element12').value =document.title;
    }
    
    // before form reset
    function before_reset() {
    
    }

    But when I hit submit, there is no reaction.

    Any other ideas ?? ?

    Plugin Contributor webdorado

    (@webdorado)

    Dear lotfus,

    Could you please give us the link to the form page, where we could check the Javascript errors?

    Thank you.

    Thread Starter lotfus

    (@lotfus)

    Actually I have a local www.ads-software.com installation, nothing is online yet.

    I installed firebug to check the javascript error, but it’s telling me: “Access to restricted URI denied.”

    I am trying to figure it out.

    If you have any other hints I am happy to hear. thanks.

    Plugin Contributor webdorado

    (@webdorado)

    Dear lotfus,

    Please be informed, that the error is not related to Contact Form Maker. And if your website is not live, please send the source code(HTML) to [email protected], and we’ll check the errors.

    Thank you.

    Thread Starter lotfus

    (@lotfus)

    Thanks a lot. I will send you an email.

    Plugin Contributor webdorado

    (@webdorado)

    Dear lotfus,

    Please change getElementsById to getElementById. Sorry for the misspell. It should look like the following:

    function before_submit() {
    document.getElementById('wdform_4_element12').value =document.title;
    }

    And should work that way.
    Thank you.

    Thread Starter lotfus

    (@lotfus)

    Wondreful! it works.

    Thanks a lot. Once it is live I will let you know ??

    Best,
    L.

    Thread Starter lotfus

    (@lotfus)

    resolved

    Plugin Contributor webdorado

    (@webdorado)

    Dear lotfus,

    Please feel free to let us know in case you have other questions.
    Thank you.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Get the current post attributes’ is closed to new replies.