The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
help with getting data from form - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: help with getting data from form (/showthread.php?tid=922) |
help with getting data from form - bonkteam - Nov 7th, 2010 hey guys, im building a database of race events and want people to fill out my form with their previous events around the globe.im having some trouble with transferring the data i get. i tried the following things and they didn't work,maybe youll be able to explain why? 1.since i have a multiple choice of events i tried using an array,each cell of the array holds different event names - i figured the formtools will put it all under the same column at the spreadsheet i receive but the only thing i get under the column is the word "array". is there any way to receive data through an array and see it in the sheet? if not.. 2.is there any way to collect a number of variables and place them under the same column in the sheet? (the way it work now is every variable gets a diffrent column) for example:if the client fills "race1" , "race2" , "race3" i want to put 3 of them seperated by commas under the "races" column. is this possible? RE: help with getting data from form - Ben - Nov 9th, 2010 Hi bonkteam, Quote:1.since i have a multiple choice of events i tried using an array,each cell of the array holds different event names - i figured the formtools will put it all under the same column at the spreadsheet i receive but the only thing i get under the column is the word "array". is there any way to receive data through an array and see it in the sheet? When you say "array", do you mean group of checkboxes? If you ever need to group all the data in a single field in the database, make sure that the set of fields all have the same name attribute, e.g. Code: <input type="checkbox" name="event[]" value="event 1" /> Event 1 That will ensure all the selected events end up in the database. The double brackets "[]" at the end will ensure it's sent as an array and Form Tools will be able to understand it. Quote:2.is there any way to collect a number of variables and place them under the same column in the sheet? (the way it work now is every variable gets a diffrent column) Exactly. Every time you use a new form field with it's own name attribute, Form Tools will assign it to a new field. Try the above approach! - Ben RE: help with getting data from form - bonkteam - Nov 9th, 2010 thanks alot for the reply ben. was wondering if the same thing will work for other types of forms besides checkbox? for example: <input type="text" class="form-textbox" id="result1" name="result1[] size="14" /> <input type="text" class="form-textbox" id="result2" name="result1[] size="14" /> <input type="text" class="form-textbox" id="result3" name="result1[] size="14" /> or drop down: <select class="form-dropdown validate[required]" name="race1[]" value="race1"> <select class="form-dropdown validate[required]" name="race1[]" value="race2"> <select class="form-dropdown validate[required]" name="race1[]" value="race3"> this are the once i need to work,got into some problems though.. thanks ben,that worked! RE: help with getting data from form - Alex1 - Nov 11th, 2010 When you receive an array,all the data that is being collected into the array fields And later is being separated by commas .Ben,is there any way of switching the commas with "enter" (\n) or ( ,the change needs to be done inside the API or is There a more simple way of doing it? RE: help with getting data from form - Ben - Nov 12th, 2010 Hey bonkteam, Yes, you can do it with select fields too. Just add the same "[]" chars to the name attribute like you did, then add two more attributes to your select: Code: <select ... multiple size="4"> That will expand the dropdown to 4 rows high and allow the user to select multiple items. Alex - Good question! I'll give this a very, very tentative "yes"......... This is something I built into the code back with the earliest 2.0.0 beta, but I've never truly tested it out (!). Just add this line to your config.php file: PHP Code: $g_multi_val_delimiter = "\n"; This overrides the default ", " value for ALL fields. Here's what I wrote in the library.php file (where it's defined): PHP Code: /** Warning: if you already have data in your form tables, this will mess it up. You'd need to manually update the records in the database to give it whatever different delimiter character(s) you choose. - Ben RE: help with getting data from form - Alex1 - Nov 17th, 2010 (Nov 12th, 2010, 11:15 AM)Ben Wrote: Hey bonkteam, thanks ben,it seems to work for almost all the options but i still have one problem left. if i have 2 text boxes for example: <input class="form-textbox" type="text" id="finish1" name="finish[]" size="4" /> <input class="form-textbox" type="text" id="finish2" name="finish[]" size="4" /> if each text-box will get only 1 or 2 characters it puts them on the same field in the table without the \n between them.the solution you suggested does work perfectly for more then 2 characters. here is an example: [attachment=88] any idea how to fix it? im trying to figure it out for hours but no luck :/ ..maybe trying to format the table diffrently in the export modules? RE: help with getting data from form - Alex1 - Nov 18th, 2010 found the bug ,thanks ben! RE: help with getting data from form - Alex1 - Nov 23rd, 2010 i got another small problem,i did switch the "," with "\n" and it works great. but then i want to do the following: my system manages race results and it excepts race names and times for each person. each person submits the following form: Race name: (finish time) Hours: Minutes: each person can enter a number of races and a number of finish times for each race. in the formtools tables they will be viewed under the column "finish times" and will be delimited by \n. since the hours and minutes are being entered seperetly,how do i force the hours:minutes to be delimited on the same line with ":" ? is this possible? can it be done with simple php on input? |