• Resolved guglielmirent

    (@guglielmirent)


    Good morning, I would like to understand how do I capture the numeric value from a link I created and insert it into a numeric field of CF7

    I have created an href link with value

    href=”#contact” class=”pbutton” data-price1=”600″

    this (600) I have to insert it after the click in a [field number] of cf7

    is this possible?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @guglielmirent

    The number 600 is not a URL parameter, database, JSON, or any other datasource. So, you can get this value via javascript directly.

    Assuming the number field is <input type="number" name="my_number">, you can insert a script tag in the form with the following piece of code:

    <script>
    jQuery(document).on('click', '[href="#contact"]', function(){
    jQuery('[name="my_number"]').val(jQuery(this).attr('data-price1'));
    });
    </script>

    Best regards.

    Thread Starter guglielmirent

    (@guglielmirent)

    Sorry but it doesn’t work, this solution!
    maybe i explained it wrong,
    the 600 is not a fixed value but a dynamic one and is part of a post-type block.
    Maybe that’s why it doesn’t work?
    the link would be :

    <a href="#contact" class="pbutton" onclick="reply_click(this)" data-prezzo="[ptb_field name='prezzo1']">[ptb_field name='prezzo1']</a>

    the onclick=”reply_click(this)” function is a script that passes me data-price=”[ptb_field name=’price1′]” in the text field, the problem is that I would need it as a numeric value to create formulas in the contact form

    maybe this makes the question a little more explicit

    thanks in advance

    Thread Starter guglielmirent

    (@guglielmirent)

    Alternatively, since my script works with text fields, I could create a hidden text field and capture the value from that hidden field and insert it into the numeric field.
    Is this possible?

    ex:

    [hidden price1 text]
    hidden text capturing the dynamic value

    [number price2]
    numeric field where it is assigned

    Plugin Author codepeople

    (@codepeople)

    Hello @guglielmirent

    The code you need is not related to our plugin because it does not use any data source.

    Actually, all of them are links with href="#contact". So, you can insert a script tag with code:

    <script>jQuery(document).on('click', '[href="#contact"]', function(){jQuery('[id="offerta_prezzo"]').val(jQuery(this).text());});</script>

    But I insist this code is not related to our plugin.

    Best regards.

    Thread Starter guglielmirent

    (@guglielmirent)

    Thank you, but my question about your plugin is whether it can retrieve data from a hidden text field and insert it into the number field, this is a related question to your plugin, would be the alternative I wrote previously

    Plugin Author codepeople

    (@codepeople)

    Hello @guglielmirent

    Our plugin populates the form fields with values stored in third-party data sources (a Database, CSV file, JSON structure, ACF, URL parameters, Posts data, or taxonomy values). But you want to assign a field the value of another. You need a basic JS script:

    <script>jQuery('[name="field-b"]').val(jQuery('[name="field-a"]').val());</script>

    Best regards.

    Thread Starter guglielmirent

    (@guglielmirent)

    Unfortunately all these scripts don’t work, or I’m doing something wrong, I can’t figure out where I’m going wrong, I was convinced that your plugin could help me, but nothing

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Get Number value After Click’ is closed to new replies.