• Resolved guglielmirent

    (@guglielmirent)


    Good morning congratulations for the plugin, I have a text fild that is pre-filled from a link on my page (the values are dynamic), I would need the values of the text field to be in a filed number, I can’t figure out if your plugin could do it for me

    an example
    href of data source:

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

    with script to polulate the filed

    [text prezzo1 readonly id:offerta_prezzo]

    script in <head>

    <script type="text/javascript">
        function reply_click(element)
        {
        document.getElementById('offerta_prezzo').value = element.getAttribute('data-prezzo');
        }    
    </script>

    my need is that the values of
    [text prezzo1 readonly id:offerta_prezzo] be transcribed into a [number sceltaofferta]

    is this possible?

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

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter guglielmirent

    (@guglielmirent)

    I tried this but it doesn’t work, where did I go wrong?

    [text provat id:offerta_prezzo]
    [dynamichidden dinamiconascosto “CF7_get_post_var key=’text provat'”]
    [number provan default:get dinamiconascosto]

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Hi! I’m taking a look now ??

    Thread Starter guglielmirent

    (@guglielmirent)

    thank you

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    The issue is with your JavaScript. You can’t set the value property directly, but need to use the setAttribute() function like this:

    document.getElementById('offerta_prezzo').setAttribute('value', element.getAttribute('data-prezzo'));

    Try that and let me know if it works! ??

    Thread Starter guglielmirent

    (@guglielmirent)

    does not work, for shortcodes how should I write them?

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Hmm… Okay, I think I know it now after a second look. I had to reread the question to better understand what you’re asking.

    To use the shortcode you’re using to populate your data-prezzo attribute, try replacing your dynamichidden form tag with this:

    [dynamichidden dinamiconascosto "ptb_field name='prezzo1'"]

    That should put the output of your custom pbt_field shortcode with the presso1 value for the name attribute as the value of that hidden field.

    Documentation for using shortcodes inside dynamic fields

    Thread Starter guglielmirent

    (@guglielmirent)

    OK the hidden field takes it, but I would like to understand how to enter it as a number value in the field

    [number provan default:get dinamiconascosto]

    because only the number field of this form needs to be visible, which I will have to use for some mathematical formulas, so I need the number visible

    Thread Starter guglielmirent

    (@guglielmirent)

    the flow is:

    1 -the customer clicks on the link

    2- the number box is automatically filled in, which will be used as the base value for the formulas

    currently to have the number value

    1- the customer clicks on the link

    2- the text field is automatically filled in

    3 – with dynamic text I capture it from the text field and assign it to the number field

    Thread Starter guglielmirent

    (@guglielmirent)

    I hope I have explained myself

    ACTUAL FLOW:

    1- link : customer click on link (link have dynamic value by ptb_field “offerta_prezzo”)

    after click in cf7

    2 – [text-field id:offerta_prezzo] (prefilled afterclick)
    3 – [dynammic text extention] get the value by [text-field id:offerta_prezzo]
    4 – [number-field] get the value by [dynammic text extention]

    in bold what I cannot do

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    For your number field the default:get attribute is a CF7 feature that pulls the HTTPS GET header, so that won’t do anything unless you’ve got ?provan=500 in your URL. You’ll want to replace that with this (not sure if you need it to be readonly, but I put it there for example):

    [number provan id:provan readonly]

    And then to copy the value from the hidden field into your number field, you’ll want to do that in JS very similar to what you did with your click listener, but instead of on click, it’ll be on page load like this:

    // Add listener when DOM tree is ready
    document.addEventListener('DOMContentLoaded', function() {
        
        // Get dynamic value
        var value = document.querySelector('[type="hidden"][name="dinamiconascosto"]').getAttribute('value');
    
        // Update your number input with the value
        document.getElementById('provan').setAttribute('value', value);
    });

    (Editing to note that I was typing this when you posted the last two comments so I didn’t see them until after)

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    ACTUAL FLOW:

    1- link : customer click on link (link have dynamic value by ptb_field “offerta_prezzo”)

    after click in cf7

    2 – [text-field id:offerta_prezzo] (prefilled afterclick)
    3 – [dynammic text extention] get the value by [text-field id:offerta_prezzo]
    4 – [number-field] get the value by [dynammic text extention]

    in bold what I cannot do

    If the hidden dynamic field and the number field are to have identical values, then do you need the dynamic field at all?

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    ACTUAL FLOW:

    1- link : customer click on link (link have dynamic value by ptb_field “offerta_prezzo”)

    after click in cf7

    2 – [text-field id:offerta_prezzo] (prefilled afterclick)
    3 – [dynammic text extention] get the value by [text-field id:offerta_prezzo]
    4 – [number-field] get the value by [dynammic text extention]

    in bold what I cannot do

    For the two bold lines 3 and 4, I’d just pull the value the same way on the click listener.

    // Your JS function on click
    function reply_click(element) {
    
        // Get the value
        var value = element.getAttribute('data-prezzo');
    
        // Update the text field (pseudo code 2)
        document.getElementById('offerta_prezzo').setAttribute('value', value);
    
        // Update the hidden input (pseudo code 3)
        document.querySelector('[type="hidden"][name="dinamiconascosto"]').setAttribute('value', value);
    
        // Update your number input (pseudo code 4)
        document.querySelector('[type="number"][name="provan"]').setAttribute('value', value);
    } 

    And their form tags would be this [hidden dinamiconascosto] and [number provan readonly]

    Since your hidden field is only being updated with a user interaction, you don’t need a DTX field.

    Thread Starter guglielmirent

    (@guglielmirent)

    the click is needed because it will not be the only link but there will be two others, so I need that if I click on link 1 the value of link 1 goes in the number field, if I click on link 2 the value of link 2 goes in the number field and the same for link 3

    the problem is that I can’t get the numeric value after the click into the number field, and I thought your plugin would help me.

    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Unfortunately, the fields provided by this plugin are dynamic in the sense that it can pull data calculated by shortcodes on page load, they are not dynamic in the way of responding to user actions (like on click). But I’m happy to help with figuring it out with you.

    Thread Starter guglielmirent

    (@guglielmirent)

    I have tried but the number field returns nothing, I honestly don’t know what to do anymore.
    it seems to me hallucinating that you can do 1000000 things with the text field and the number field is not populated by a simple link.
    if I give you the user name and password would you take a look?

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘assign a number field the value of text field cf7’ is closed to new replies.