Posts: 2
Threads: 1
Joined: Nov 2010
Reputation:
0
Nov 7th, 2010, 2:45 PM
(This post was last modified: Nov 7th, 2010, 2:48 PM by bonkteam.)
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?
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
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
<input type="checkbox" name="event[]" value="event 2" /> Event 2
<input type="checkbox" name="event[]" value="event 3" /> Event 3
<input type="checkbox" name="event[]" value="event 4" /> Event 4
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
Posts: 2
Threads: 1
Joined: Nov 2010
Reputation:
0
Nov 9th, 2010, 11:23 PM
(This post was last modified: Nov 9th, 2010, 11:32 PM by bonkteam.)
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!
Posts: 5
Threads: 1
Joined: Nov 2010
Reputation:
0
Nov 11th, 2010, 12:31 AM
(This post was last modified: Nov 11th, 2010, 12:33 AM by Alex1.)
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?
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Nov 12th, 2010, 11:15 AM
(This post was last modified: Nov 12th, 2010, 11:17 AM by Ben.)
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: /** * This determines the value used in the database to separate multiple field values (checkboxes and * multi-select boxes) and image filenames (main image, main thumb, search results thumb). It's strongly * recommended that unless you have a programmatical reason, you should leave it to the default comma-space * value. * @global string $g_multi_val_delimiter */ $g_multi_val_delimiter = ", ";
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
Posts: 5
Threads: 1
Joined: Nov 2010
Reputation:
0
(Nov 12th, 2010, 11:15 AM)Ben Wrote: 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: /** * This determines the value used in the database to separate multiple field values (checkboxes and * multi-select boxes) and image filenames (main image, main thumb, search results thumb). It's strongly * recommended that unless you have a programmatical reason, you should leave it to the default comma-space * value. * @global string $g_multi_val_delimiter */ $g_multi_val_delimiter = ", ";
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
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:
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?
Posts: 5
Threads: 1
Joined: Nov 2010
Reputation:
0
found the bug ,thanks ben!
Posts: 5
Threads: 1
Joined: Nov 2010
Reputation:
0
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?
|