Join our DNN Community    (Newsletter, Tips, Tricks and Forums for DNN Skins & Modules)

 


 
Microsoft Gold Certified Partner - DNN Benefactor

DotNetNuke Powered! 


Friday, December 05, 2008 Register · Login · Contact · Search:  
Company Solutions Portfolio Contact
Forums
Samples and other shared info.

Subject: Using Checkboxes in Lists

You are not authorized to post a reply.   
Page 1 of 212 > >>
Author Messages
pauldes
Immortal
Posts:1392

09/02/2006 12:23 PM Alert 
This is a simple ListX that shows how to implement the use of CheckBoxItems in a grid, and then perform actions with the checked items the user selects. In the example checked items are deleted when you click the links at the bottom of the ListX. One utilizes a message action to delete, the other utilizes AJAX.

You can also perform actions with UNchecked items. This example doesn't go into it but it is covered in the Session Variable Name heading in the Checkbox section of the manual.

Files in CarsGroup.zip

CreateCarsTable.SQL - USE ONLY IF YOU HAVE NOT INSTALLED THE MyFirstListX sample in this forum. Run this script with a query tool or from HOST>SQL, to install the application table to your DNN database.

PopulateCars.SQL - USE ONLY IF YOU HAVE NOT INSTALLED THE MyFirstListX sample in this forum. Follow same procedure as CreateCarsTable.SQL

CarCheckboxItems.xml - the ListX module. Add a new page to your site. Add a ListX module. From the module menu choose View Options. Click the XML icon. Replace ALL text in the XML text field with the contents of this file. Click the LOAD link. Click the SAVE CONFIGURATION link.

Attachment: CarCheckboxItems.zip


ListX....makes you look brilliant, even though you're not.
deburca
Flyweight
Posts:4

10/28/2006 1:47 PM Alert 
Excellent, that is really useful, especially the delete via Ajax example - can we have more Ajax examples in this forum?

James
kevinmschreiner
Please Wait...
Posts:749

10/28/2006 2:25 PM Alert 
Yes - actually - I'll have a LIstX Chat example up in the next few days. It's actually online now, I just want to make it look nicer.

Kevin M Schreiner

Business Intelligence Force, Inc. (bi4ce)
Raynell
Middleweight
Posts:53

11/22/2006 9:56 AM Alert 
Hi,

is there a way to do checkboxes (created dynamically from a table) in which a user can select the ones they want and when the come back and the items they check are stored in a table, when the checkboxes are rendered the items they selected are checked.

Further clarification:

table Genres has values that will be displayed as checkboxes 4 in a row. the user will select items and store them in a configuration table. when the user wants to edit their profile, the genre list is re rendered and the items stored in the configuration table is called to put a check mark in the list of displayed genres.

I hope you can help
Ray
emaynard
Heavyweight
Posts:182

11/25/2006 10:25 PM Alert 
I also replied to this in the General Module topic as well, but this seems a more appropriate place, so I'm posting here as well.

Replace the (LT)'s and (GT)'s with the appropriate html bracket and this should do what wyou need Raynell. Of course the underlying data support is left to you.


{SUBQUERY,
Name="qry_Checkbox",
Query="Select [lookup_value_column], [lookup_text_column] from [Your_lookup_Data_table]",
Format="(LT)input type=checkbox' name='frm_CheckboxFormField' value='[lookup_value_column]'(GT)[lookup_text_column](LT)br /(GT)",
SelectedFormat="(LT)input type='checkbox' name='frm_CheckboxFormField' value='[lookup_value_column]' CHECKED(GT)[lookup_text_column](LT)br /(GT)",
SelectedField="lookup_text_column",
SelectedItems="[FormDataTableColumn]",
UseCache="False"}


Hope this helps,

-eric
emaynard
Heavyweight
Posts:182

11/26/2006 11:21 AM Alert 
Ok,

Here is one solution to the formatting issue. Borrowed this from the following topic:

http://dnn.bi4ce.com/Forums/tabid/106/view/topic/forumid/22/postid/2300/Default.aspx


{SUBQUERY,
Name="qry_Checkbox",
Query="Select [lookup_value_column], [lookup_text_column] from [Your_lookup_Data_table]",
Format="(LT)span style=\"display: block; width: 200px; float: left;\"(GT)(LT)input type=checkbox' name='frm_CheckboxFormField' value='[lookup_value_column]'(GT)[lookup_text_column](LT)/span(GT)",
SelectedFormat="(LT)span style=\"display: block; width: 200px; float: left;\"(GT)(LT)input type='checkbox' name='frm_CheckboxFormField' value='[lookup_value_column]' CHECKED(GT)[lookup_text_column](LT)/span(GT)",
SelectedField="lookup_text_column",
SelectedItems="[FormDataTableColumn]",
UseCache="False"}


I tried the ALTERNATE tag first, but it appears to only work with the module query and not sub queries. That's O, since the SPAN solution seems to work just as well.

Just adjust the width attribute to the desired approx. column width. For example 600px module / 200px SPAN should yield 3 columns per row.

Not quite sure how you might limit by rows, but I think that there is probably less need for that formatting anyways.

-eric

Raynell
Middleweight
Posts:53

11/26/2006 11:36 AM Alert 
Thanks..!

..I have litterally spent 3 days on this and now I have my answer to that one. Now the question is how do I check the correct box from the list that is stored in another table for a specific user when they save?

=)
Raynell
Middleweight
Posts:53

11/26/2006 11:36 AM Alert 
BTW... that worked great!
DavidWSnow
Cruiserweight
Posts:127

12/04/2006 5:43 PM Alert 
Another, more interesting to me, checkbox issue is using them for data. I have a table with several "bit" fields. I can display them in a form as text "True" but can't display them in checkboxes or radio buttons.

If try to update the record when they are text I get errors trying to stuff "True" into a bit.

/dave
emaynard
Heavyweight
Posts:182

12/04/2006 10:12 PM Alert 
Dave,

If I understand your problem correctly, you are saying your solution does not allow you to use Checkboxes, but instead you have to use a Text field.

I personally would be concerned about users having to type the whole word True or False, but I'm sure that there are times when you have to do things you normally want to do. If I had to display the bit fields as text, I think I would use a < select > with the hardcoded values like this:

(LT)select(GT)
(LT)option value="1"(GT)True(LT)/option(GT)
(LT)option value="0"(GT)False(LT)/option(GT)
(LT)/select(GT)

Also, I'm not sure why True and False don't insert in to your tables, because I'm pretty certain those would be valid input for a bit field.

hth,
-e
DavidWSnow
Cruiserweight
Posts:127

12/05/2006 1:24 PM Alert 
My problem has several parts:
I took the "cars" sample and tweaked it to my database. I have several columns that are datatype of "bit" and show up in a form as checkbox or radio.
When I select a record from the listing and jump to the details page the fields don't get filled in.
DavidWSnow
Cruiserweight
Posts:127

12/05/2006 2:18 PM Alert 
My problem is as follows. I took the "cars" sample with a List and a detail/edit page and tweaked it to fit my database. My database has several "bit" fields such as IsHosted or IsOnDList which I am trying to display on a form as checkboxes. If the data is "true" in the database nothing shows up in the box. No errors are visable.
If I update the record the "true" if checked or "false" if unchecked makes it back to the database. When I expand to my full design I will have a dozen or more bit fields, so I really need this to work.
dcampbell
Heavyweight
Posts:197

12/05/2006 3:19 PM Alert 
David
In your IIf statement what are you checking for to determine if the value should be checked?

Dave

Dave Campbell
Software Engineer
Business Intelligence Force, Inc. (bi4ce)
DavidWSnow
Cruiserweight
Posts:127

12/05/2006 3:57 PM Alert 
I don't have any IIF statements. I am asuming that the box should get filled in if the bit is set in the database and be cleared if the value is false or NULL. When I set the bit in the forma and do an update the bit does get set in the database. This was a real suprise to me, since I assumed that the problem should have been bidrectional.

Equally surpeising what that I couldn't get the "cars" example to add a new records, but mine does that ok.

/dave
bgates
Heavyweight
Posts:197

12/05/2006 5:06 PM Alert 
Bit fields are a bit (bad pun) of an annoyance. The problem is SQL treats them as a 1 or a 0, but .NET treats them as boolean True or boolean False.

1) Add a Query Variable
Name: @IsHosted
Type: <Form>
Source: chkIsHosted
TargetLeft:
TargetRight:
TargetEmpty: 0

2) Add your checkbox
<input type=checkbox id=chkIsHosted name=chkIsHosted value="1" {IIF,"'[IsHosted]'='True'","CHECKED",""}>Is This Hosted?

3) In your Update Action, use @IsHosted as opposed to [chkIsHosted,Form].

The problem is with checkboxes in general. The value attribute is only posted to the form if it's checked. Otherwise, the checkbox is not even posted. Thus, the value is empty, which is why you set the Query Variable to "0" when the field variable is empty. The {IIF} tag is the only way to ensure that the checkbox is checked upon returning. It converts [IsHosted] column value into a string, and compares that against the string value 'True', which matches when the SQL value is 1.

Bob Gates
Business Intelligence Force, Inc. (bi4ce)
DavidWSnow
Cruiserweight
Posts:127

12/05/2006 6:37 PM Alert 
Thanks that appears to have fixed the checkbox issue.
I already had a variable fldIsHosted = @IsHosted so all I needed with the {IFF.....}

Thanks,
DavidWSnow
Cruiserweight
Posts:127

12/06/2006 12:38 PM Alert 
Now the cehkbox displays properly, but won't update when it is checked. The actual sql in the update statements show 'False'. Attached is the current fragment of the display
<TABLE WIDTH="75%" border="2" >
<TR class="DataGrid_Header">
<TD>Attribute</TD>
<TD>Value</TD>
</TR>
<TR class="DataGrid_Item">
<TD>On List:</TD>
<TD>
Dotti <input name='fldIsOnDList' value='[IsOnDList]' type='checkbox' {IIF='',"'[IsOnDList]'='True'","CHECKED",""} >

</TD>
</TR>

The W3C folks sure make checkboxes fun for developers ;=}
/dave
pmanda
Superweight
Posts:267

12/06/2006 1:38 PM Alert 
In the Input tag try removing value='[IsOnList]' .
Hope this should work.

Praveena Manda
Software Engineer
Bi4ce,Inc
DavidWSnow
Cruiserweight
Posts:127

12/06/2006 3:11 PM Alert 
That now tries stuffing the value 'on' into the database and gets an error converting it to a bit value
/dave
emaynard
Heavyweight
Posts:182

12/06/2006 4:29 PM Alert 
David,

Perhaps you can apply the information in this thread about radio buttons to your checkbox issue.

http://dnn.bi4ce.com/Forums/tabid/106/view/topic/forumid/7/postid/2001/Default.aspx

-e
You are not authorized to post a reply.
Page 1 of 212 > >>




ActiveForums 3.6
Latest Post
 
At R2integrated (formerly Bi4ce), we take support seriously.  That's why we support our customers and DNN community with daily monitoring from our experienced engineering team.  We ask that the first step taken is to read the relevant documentation and support forums prior to submitting any questions that may already be available or have been answered.  We ask that you review the documentation that we provide for our products before posting a question.

The Forums are for our customers to chat, exchange ideas and strategies, and submit feedback.  Please be sure to perform keyword searches for previous related forum responses.

To be helpful when submitting a new item, please include the following: 
  1. DNN Version
  2. Module Version
  3. Admin Log Viewer Information
  4. Environment detail: Operating system, .NET framework version, database and version, IIS version, Browser version (if appropriate)
We always try to respond quickly and monitor the forums daily during business hours (EST).  Occasionally, requests for a specific project requirement may not apply for the free support offered. For project specific support please submit via our Information Request form.

Thank you for using our Forums.

Click here to register for the Forums
 
© 2008 by R2integrated (formerly Bi4ce) | DNN® is a registered trademark of DotNetNuke Corporation