This topic is locked

checkboxes

6/27/2006 2:38:23 PM
PHPRunner General questions
A
amirgulamali author

i want a single feild having several checkboxes, allowing the user to check more than 1 checkbox. i tried looking around and i couldnt find the solution, in view as, i can get 1 checkbox, how can i use several checkboxes for 1 feild
thanx

O
osluk 6/27/2006

One field one one check box is how it is to keep things logical anyway.
Try to explain more about what you are trying to record so I can understand better.
Cheers Chris

A
amirgulamali author 6/29/2006

ok just like we can have a MULTISELECT LIST for a single field where the selected values are stored in a single field. (comma separated list)..
can checkboxes be used in a similar way?


like can all the values of the fields be stored in one column like "TOPPINGS" ?

O
osluk 6/29/2006

OK I see what you mean it might be a single field from the choosers point of view but the data chosen (potentially multiple items) would then need to be combined and stored in a single field (messy to search) but possible.
This is what you need a field for each choice to generate your options then concatenate the chosen options into a single field and store it.
It needs a more PHP literate person to turn that into the required code.

Sounds like a manual mod to the edit page so not for the faint of heart.

PHP doesnt take any prisoners!
Hope this moves you along a bit.
Cheers Chris

A
amirgulamali author 6/30/2006

thanx for ur 2 cents chris.. i guess different fields would be the safest way to do it... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=9524&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=9524&image=2&table=forumreplies' class='bbc_emoticon' alt=':blink:' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=9524&image=3&table=forumreplies' class='bbc_emoticon' alt=':blink:' />

O
osluk 6/30/2006

Different fields would be needed to generate the checkboxes and best to collect it in different fields too.
BUT if you then needed a single field it sould be possible then to collect up the toppings and concatenate them into a field for users saying top1 - top2 - top3 etc
Get the mechanics of the thing working first then refine it.
Remember the users dont see any of the messy stuff of multiple fields.
Easier then to search for all order that included peperoni if they are in different fields.
Cheers Chris

T
thesofa 9/15/2006

just a random thought about this, could you assign a numerical value to each type of topping, e.g. cheese = 1, pepperoni = 2, salami = 4, mushroom = 8.

store the values as binary, add the values together as decimal first, then convert to binary and store the binary value.

searching could then be done through a binary AND or OR match, not sure which, to see if the topping was chosen?

each topping value would be the next power of 2 up, hence 16,32,64,128 etc.

I am sure the searching would be easier that way?

D
Dale 9/16/2006

Another thought,
How about making one field in the database as a varchar field labeled Selected Toppings.

In phprunner, make view and edit as lookupwizard with multiselect or multiline.
Then you could manually add the checkboxes on the add, edit and view pages.

With a bit of javascript,

  • Hide the Selected toppings field.
  • Make the checkboxes checked based on the Selected values of the Selected toppings data value.
  • using the onChange function on the checkboxes you could update the selected values of the hidden Selected toppings field.
    just a thought