itsberni Posted October 15, 2019 Share Posted October 15, 2019 Hi Guys, i use the embed-method "D" in Formbuilder. In the form i use some checkboxes for calculating. To achieve this i set the value of the checkbox like this: <input name="myCheckbox" type="checkbox" value="<?= $someValue ?>" /> When i send the Form, the value changes into the entry, i made in formbuilder in the Detail-Section of the checkbox-field. does anybody know, how to accomplish, that the Form sends my specific value? many thanks! Link to comment Share on other sites More sharing options...
dragan Posted October 15, 2019 Share Posted October 15, 2019 I'm confused. Are you using checkboxes or radio buttons? Unless you don't check the relevant radio button, you won't get any value after submitting the form. Or maybe I don't understand what you're really asking? Link to comment Share on other sites More sharing options...
itsberni Posted October 15, 2019 Author Share Posted October 15, 2019 4 minutes ago, dragan said: I'm confused. Are you using checkboxes or radio buttons? Unless you don't check the relevant radio button, you won't get any value after submitting the form. Or maybe I don't understand what you're really asking? Sry for confusion.... corrected the Post. Link to comment Share on other sites More sharing options...
itsberni Posted October 16, 2019 Author Share Posted October 16, 2019 something for further explanation: I want to calculate a price using checkboxes: e.g. checked state <input name="myCheckbox" type="checkbox" value="15" /> unchecked <input name="myCheckbox" type="checkbox" value="0" /> the change of the value happens via js. now, in case of submission, the value in the Database is that one ( Detail - Tab of the FB-Field ) These entrys appear as well in a page ( i create a page with this data ) as in the admin-Email. it seems to be, that FB ignores my specific value in case of submission. i also tried to let this fields empty to force the use of my values but the first one is mandatory. that works neither. Some ideas.....? Link to comment Share on other sites More sharing options...
OLSA Posted October 18, 2019 Share Posted October 18, 2019 I don't use Form builder, and maybe I don't understand your problem, but - in case of unchecked field - on server side you will not have any value ( just like that field doesn't exist). On 10/15/2019 at 2:07 PM, itsberni said: When i send the Form, the value changes into the entry On 10/16/2019 at 6:04 AM, itsberni said: the change of the value happens via js. I understand this like that you - on submit event - change/set checkbox value? If this is the case, do you 1) prevent default submission event, 2) change checkbox value, and after that, 3) proceed submission? Something like this: // basic example $("form").on("submit", function(e) { // stop submission e.preventDefault(); // set checkbox value // ... // proceed submission $(this).submit(); // or return true or... }); But if not, than form will not send checkbox value because it's happens later (after submit). If all this is not a problem, maybe you can try to use different approach? As example, use hidden field - and - use checkbox change event to set it's value. Or, another could be to use select field and maybe you can think about that option? Regards. Link to comment Share on other sites More sharing options...
itsberni Posted October 21, 2019 Author Share Posted October 21, 2019 Thanks for sharing your thoughts. i'll try to solve it with a hidden field for each checkbox. Link to comment Share on other sites More sharing options...
rick Posted October 21, 2019 Share Posted October 21, 2019 @itsberni, I'm not sure I understand your specific use case completely. When you say "Form sends my specific value", there are only two values for a checkbox when submitted: It's either present or not. For example: if( isNull($input->post('YourCheckboxFieldNameHere')) ) { // User did not check checkbox, so set a default or whatever. } If your specific value (used in your computations) is numeric, ie, a dollar amount, or temperature, or distance measurement, etc., then you will need to use an input type that accepts numeric entries. The checkbox is not the correct input type for your data. I don't use form builder so I can't provided specific instructions. In HTML it would be the input type text. Can you be more elaborate with what you are trying to accomplish? I'm sure someone here will have the answer you seek. Link to comment Share on other sites More sharing options...
itsberni Posted October 22, 2019 Author Share Posted October 22, 2019 Hi Rick, this was my misunderstanding. I had the opinion that i could set a specific value to a checkbox. my usecase is a form, where you can choose ( via checkbox ) different "products". Every product has, of course, it‘s own price. When Checkbox is Chosen and the form is sent the value of the checkbox should be submitted - that was my thought - misbelief ? thank you though.... Link to comment Share on other sites More sharing options...
rick Posted October 22, 2019 Share Posted October 22, 2019 If you allow the user to select one or more products, you can use a select field to present the options to the user. Of course it depends on the number of available products. If there are a large number of products, you may want to separate them by category. The select field's options allow for values that you require. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now