Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Checkbox Selection order

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

Phil.
World Chat Champion



Joined: 02 Feb 2002
Karma :

PostPosted: 22:47 - 22 Jun 2010    Post subject: Checkbox Selection order Reply with quote

Hey

I thought i'd be able to find something about this but try as i might I can't find anything remotely useful, maybe I my search doesn't explain the problem very well, anyway..


So I have a bunch of check boxes that go towards creating a report. Each checkouts toggles the inclusion of a particular metric when the form is submitted and the report is run.

I'd like to be able to return the columns in the order in which the check box buttons were checked.

e.g:
Metric Checked Order
A --------------- 2
B --------------- 1
C --------------- 3


Report

B | A | C
----------
X | Y| Z

I was thinking of adding onclick events and getting the name of the checkbox, storing that in an array, or writing it to a hidden text field or something of that kind, but seemed like it would very very messy, hoping a simpler solution could be suggested.

Thanks
 Back to top
View user's profile Send private message Visit poster's website You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 22:57 - 22 Jun 2010    Post subject: Reply with quote

Hi

Think using hidden fields populated when the checkboxes are ticked would be how I would do it. Down side is that it means it only works if they have javascript enabled (if that matters to you).

Difficult bit is faffing round removing items when they uncheck a check box.

Failing that simulate a pair of list boxes, one for possible fields and the other for selected fields. Click to move between them (or drag and drop is you are feeling flash). When the form is submitted copy the selected fields to an array of hidden fields to pass back to the server.

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Phil.
World Chat Champion



Joined: 02 Feb 2002
Karma :

PostPosted: 13:00 - 23 Jun 2010    Post subject: Reply with quote

Hey Kieth, thanks for the response.

Ended up using a hidden field. Had contemplated using drag an drops but was concerned it was adding an extra step.

So anyway, incase anyone ever stumbles on this one day and wants some code to look at:

Using the $F function from the prototype Library
Code:

<script type="text/javascript">
   function doc_write($name){
      document.getElementById('test').value=$F('test') + $name + '-';
   }
</script>

<input type="checkbox" onclick="doc_write('some_name')" name="some_name">

<input type="hidden" id="test" name="test" value=""/>


Then I guess I will explode the '-' from $_GET['test'] and loop through those to get the order. Deleting duplicates along the way.
 Back to top
View user's profile Send private message Visit poster's website You must be logged in to rate posts

Kickstart
The Oracle



Joined: 04 Feb 2002
Karma :

PostPosted: 21:24 - 23 Jun 2010    Post subject: Reply with quote

Hi

Possible, although you could also use you function to add a hidden field each time. Saves the explode (which has potential issues if the value happens to contain whatever you are using as a delimiter).

All the best

Keith
____________________
Traxpics, track day and racing photographs - Bimota Forum - Bike performance / thrust graphs for choosing gearing
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts
Old Thread Alert!

The last post was made 16 years, 77 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.06 Sec - Server Load: 0.2 - MySQL Queries: 13 - Page Size: 43.17 Kb