Fill text box on a click of a button


(Menino) #1

Hey Rapidweaver Community,

I would like to know how to use a button group stack to enter a value into a text area upon a click? As seen on the UN website, if I click on $35 then the text area holds the value of $35, and as I click on $50 the value on the text area changes to $50.


https://give.undp.org/give/120717/#!/donation/checkout

Thanks,
Menino


(Rob Beattie) #2

It would be worth looking at 1LD’s Formula stack. That might do it.

https://onelittledesigner.com/rapidweaver-stack/formula/

Rob


(LJ) #3

Yes, this is a very useful looking stack. What I’m particularly interested in is the ability to export the values to any form. Don’t suppose you’ve tried this with Formloom?


(Rob Beattie) #4

I haven’t I’m afraid. Maybe someone else has?


(Joe Workman) #5

I have not tested this at all but if you can add an onclick attribute to the button then try adding this code to a button…

document.querySelector('input[name=amount]').value=75

You will need the custom the name of the input from amount to whatever you are using. And obviously the value as well.


(Greg Schneck) #6

I don’t understand what you are trying to achieve. Why not just make the amount buttons do what the form entry is doing? ie: click on the $35 button and it adds $35 to the cart? Having a button fill a form seems like an extra un-needed step to me but I’m probably missing something. For my “donations” I have buttons that will add specific amounts but I also use a form so the user can enter a different amount if they wish. But 95% of contributors use a fixed price button which directly adds the amount to the cart. Again, apologies if I’ve missed you goal.


(Pat Reynolds) #7

Probably not exactly answering the question that you asked but if its of any use for you to know, I collect user information from forms in a website made with Formloom3 to Google Sheets. It works great. Here is the set up: https://yabdab.zendesk.com/hc/en-us/articles/205171855-Formloom-3-and-Google-Sheets-Setup.


(Menino) #8

I will try this method and see. Hope it works out. To clarify I am just using the foundation button group and number input stack.


(LJ) #9

Not what I was asking there but very useful to know anyway - thanks


(Joe Workman) #10

I whipped up an example of this working using my Foundation stacks… http://sandbox.joeworkman.net

A small tweak to what I said earlier. Instead of using onclick set the URL to be this… (with the corresponding changes like I mentioned earlier.)

javascript:document.querySelector('input[name=amount]').value=50

(Menino) #11

Thank you Joeworkman!


(system) #12

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.