R2i DotNetNuke® Forum

R2i wants you to have the opportunity to ask questions, post reviews, help others or just rant and rave about DotNetNuke® or any of the R2i Modules and Skins. Our team spends hour upon hour, day after day, working on custom DotNetNuke® modules and services; please feel free to ask us anything.
 
Simple checkbox question
Last Post 01 Jan 1900 05:00 AM by . 1 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Informative
redventoUser is Offline
New Member
New Member
Posts:2

--
15 May 2007 04:11 PM  
I have an editor that has a true/false field that I have displaying properly (ie it is checked when true, unchecked when false) however I am having a problem getting it to update properly when I uncheck the box. I know it is in this line:

<input name="txtInv" type="checkbox" value="1" {IIF,"'[In_Inventory]'='True'","CHECKED",""} {IIF,"'[In_Inventory]'='1'","checked",""} />In Inventory?

And I am fairly certain it is the value="1" however where the stupid kicks in is that I have no idea how to set it so that when checked value = 1 and unchecked value = 0

thanks in advance.
kevinmschreinerUser is Offline
Advanced Member
Advanced Member
Posts:729

--
19 May 2007 09:05 PM  
Okay, the problem with checkboxes and the web is simple - the standard is stupid, not the user. Just so you get the total idea - if you have a checkbox called txtInv, and the value is set to 1 in the attributes - then when checked the value posted to the server is 1, but when unchecked - the value is completely missing. Meaning - it either has a value, or it is completely missing from the postback.

With that said, here is how you can handle your issue :

Knowing what you now know - there is NO unchecked value, you have half the solution already marked out for you.

Assume that we are updating your database by saying =
UPDATE myTable set [In_Inventory]=@txtInv

Now - you want to define the Query Variable in the Variables area of ListX. This is where you can handle your dilemma.

In the Query variable - plug in the form object name and @txtInv as the target. The left and right should both be single quotes - because you want to always make sure you are secure against SQL Injection.

The empty value can either be '' (two single quotes) or 0 (zero). If your SQL table is using a bit flag, this will automatically translate as True or False. Also - SQL is smart enough to automatically translate an empty string value '' as 0 anyway.

Does that make sense?
You are not authorized to post a reply.

Active Forums 4.1
 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seatle, WA • 410.327.0007 • info@R2Integrated.com

Bookmark & Share Bookmark and Share