jokecoat
Posts: 43
|
| Posted: 01/11/2008, 6:33 AM |
|
Can someone please help me with this problem.
I want to store multiple values in one databasefield using checkbox.
Q: what kind of field should i use (text, blob etc)?
Q: what events should i use?
|
 |
 |
datadoit
|
| Posted: 01/11/2008, 6:44 AM |
|
jokecoat wrote:
> Can someone please help me with this problem.
>
> I want to store multiple values in one databasefield using checkbox.
>
> Q: what kind of field should i use (text, blob etc)?
> Q: what events should i use?
> ---------------------------------------
Clarify a lil'... store multiple values from several fields on a form
that's being submitted? or statically assigned values based on the value
of a checkbox control [on a form]? The latter doesn't require programming.
Can't help you with how to define your field if we don't know the type
of data you're storing (text, pictures, what?). Knowing the database
engine you're using and how you plan to retrieve and display the data
would help too.
Be more specific and we'll get you going in the right direction.
|
|
|
 |
jokecoat
Posts: 43
|
| Posted: 01/11/2008, 7:44 AM |
|
OK sorry.
I want to use a checkboxlist and users can (and will) select more than one item from the list.
These values i want to put in one databasefield.
I use a grid/record page, so there should also be a possibility to change these values.
The data i'm storing are numbers e.g.
id value
1 value1
2 value2
I want the id's to be stored.
Database is mysql.
Hope you can help me out.
|
 |
 |
datadoit
|
| Posted: 01/11/2008, 9:12 AM |
|
Excellent. Start here:
http://examples.codecharge.com/ExamplePack/ManyToManyCh...anyCheckbox.php
See if that helps.
|
|
|
 |
jokecoat
Posts: 43
|
| Posted: 01/14/2008, 2:13 AM |
|
I had a look at that example, but i want my values stores in one field commaseperates, eg. 1,3,4
anyone an idea?
|
 |
 |
datadoit
|
| Posted: 01/14/2008, 6:01 AM |
|
See this post: http://forums.codecharge.com/posts.php?post_id=60507
It talks about how to access control values that are stored in arrays.
Then, add a hidden field to your form bound to the field you want to
update. You could use javascript in the form's OnSubmit event to assign
the hidden field's value to the values of your checkbox control array.
Read the above post first to see if it sheds any light.
|
|
|
 |
feha
Posts: 712
|
| Posted: 01/26/2008, 9:38 AM |
|
Hi
as datadoit said ...
please check this code and you will get a clear picture 
$s_list = "";
if ($Component->question_type->GetValue() == 4)
$s_list = CCGetParam("a_checklist", "");
if ($Component->question_type->GetValue() == 5)
$s_list = CCGetParam("a_multilist", "");
if (count($s_list) > 0 AND is_array($s_list)) {
foreach ($s_list as $key => $value) {
if ($Component->a_multi_response->GetValue() != "")
$Component->a_multi_response->SetValue($Component->a_multi_response->GetValue() . ",");
$Component->a_multi_response->SetValue( $Component->a_multi_response->GetValue() . $value);
}
}
So it stores values , in one db field ....
checkbox list or multiple select lisbox ....
but (note) this is not flexible as you can store max 256 characters in chvar type filed ...
you could use text or blob and you could use a trim() function to clean up start-end white spaces ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |