ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 7th, 2004, 12:52 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
Getting Checkbox to populate checked fields

ok...so i have 2 check boxes labeled Y and N. When the user initially fills then in it sends either a Y or N to the tLetter column in my database....

I have been looking for code and found this and can not get it to work


Code:
<cfquery name="Recordset1" datasource="Vacancy">
SELECT * FROM dbo.changerequest
where idnum = '#URL.recordID#'
</cfquery>

<cfset letter = Recordset1.tLetter>

and below is the input box on my form...

<font size="1">forwarded a copy to HR? Y 
                            <input name="tLetter" type="checkbox" id="tLetter" 
	<cfif ListFindNoCase(letter,"Y")>checked</cfif>>


any ideas why this isnt working....??? when i go into my DB the field definately is labeled with a Y....

Reply With Quote
  #2  
Old September 7th, 2004, 01:03 PM
EBP2K2 EBP2K2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 48 EBP2K2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
what are you trying to do again, trying to have the appropriate checkbox initially checked?

Reply With Quote
  #3  
Old September 7th, 2004, 01:05 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
yea

Like someone fills out one form, then someone goes back into open the form from a link and I want the form input checkbox for Yes to have a check if there is a Y in the database from the previous user that filled out the initial form. Make sense?

but basically yes, i want them to have the correct checkboxes checked if someone wants to reopen the form.

Reply With Quote
  #4  
Old September 7th, 2004, 01:08 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Can you not just do <cfif letter>selected</cfif>?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #5  
Old September 7th, 2004, 01:08 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Also are you sure the database isn't putting in a Y by default?

Reply With Quote
  #6  
Old September 7th, 2004, 01:11 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
I know it isnt putting the Y in by default b/cause it passes a null value if nothing is put in, Y if they select the Y box and N if they select the N box.

Basically I need to learn how to have checkboxes checked on forms from an initial form...here is the flow of this form...

1. user fills out form, checks boxes where appropriate....

2. user goes to page that shows linked names of forms they filled out and click link

3. link opens an update page...now I need the same checkboxes to be checked as where on the first page....

Reply With Quote
  #7  
Old September 7th, 2004, 01:11 PM
EBP2K2 EBP2K2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 48 EBP2K2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Quote:
Originally Posted by JackSNVC
Like someone fills out one form, then someone goes back into open the form from a link and I want the form input checkbox for Yes to have a check if there is a Y in the database from the previous user that filled out the initial form. Make sense?

but basically yes, i want them to have the correct checkboxes checked if someone wants to reopen the form.


if you are trying to pass form between pages, just use session to save it... but in your case, fetching from database, kiteless is right, you can use cfif statement within the input tag...


Code:
<cfquery name="Recordset1" datasource="Vacancy">
SELECT * FROM dbo.changerequest
where idnum = '#URL.recordID#'
</cfquery>

<cfset letter = Recordset1.tLetter>
<cfinput type="checkbox" required="no"
checked="<cfif letter eq Y>yes<cfelse>no</cfif>">


no? i think it should work..

Reply With Quote
  #8  
Old September 7th, 2004, 01:11 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
yea

I know it isnt putting the Y in by default b/cause it passes a null value if nothing is put in, Y if they select the Y box and N if they select the N box.

Basically I need to learn how to have checkboxes checked on forms from an initial form...here is the flow of this form...

1. user fills out form, checks boxes where appropriate....

2. user goes to page that shows linked names of forms they filled out and click link

3. link opens an update page...now I need the same checkboxes to be checked as where on the first page....

Reply With Quote
  #9  
Old September 7th, 2004, 01:15 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
check

well i put this in

checked="<cfif letter eq "Y">yes<cfelse>no</cfif>"

and now everytime i reload the page whether the Y is a Y in the database or not it selects the Y checkbox...

Reply With Quote
  #10  
Old September 7th, 2004, 01:44 PM
EBP2K2 EBP2K2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 48 EBP2K2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Quote:
Originally Posted by JackSNVC
well i put this in

checked="<cfif letter eq "Y">yes<cfelse>no</cfif>"

and now everytime i reload the page whether the Y is a Y in the database or not it selects the Y checkbox...


k, this should work -->

Quote:
<cfif letter eq "Y">checked="yes"<cfelse></cfif>


i guess cfinput doesnt accept checked="no" ... so just return nothing after cfelse... it worked for me.

Reply With Quote
  #11  
Old September 7th, 2004, 03:01 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
checks

nah bro now it just doesnt show anything....I don tsee why it is so hard to just do this....I have looked all over the web for this stuff too and cant find it

Reply With Quote
  #12  
Old September 7th, 2004, 03:06 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
With all this discussion I'm still not clear what you are trying to do. Is it this: if the database has the value 'Y' for one field, then when you display that record you want a checkbox checked for that value?

If that is correct, then this is all you need to do:

<cfset myFlag = 'Y' />

<input type="checkbox" value="Y" <cfif myFlag eq 'Y'>checked</cfif>>

Reply With Quote
  #13  
Old September 7th, 2004, 03:25 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
kiteless doesnt that always set the value to Y? It leaves the checkbox always checked. There is also a N check box and they are both named tLetter. If the first user who filled out the form clicks on the N text box then the DB will populate with a N. so either if it is Y or no and someone else goes to look at the form at a later date. i want the checkbox to have the appropriate one checked. All of the options given to me thus far have either left it checked no matter what or done nothing. I have in my db like 5 examples 2 w/ y's in the tLetter field and 3 w/ N's. And when I run all of these examples it doesn't show up correctly.....u get what I am saying now?

Reply With Quote
  #14  
Old September 7th, 2004, 03:40 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Well first, if you want this to always either be yes or no, you should use a radio button not a check box.

But aside from that, no I don't see what you are saying. If your database field has an N in it for the field myQuery.booleanField, then this code would have the NO box checked:

<input type="checkbox" value="Y" <cfif myQuery.booleanField eq 'Y'>checked</cfif>> Yes
<br>
<input type="checkbox" value="N" <cfif myQuery.booleanField eq 'N'>checked</cfif>> No

Reply With Quote
  #15  
Old September 8th, 2004, 07:56 AM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
well

Well the thing is is they are optional Yes or No's....Neither has to be selected for the form to go through. I dont know why but none of these code lines that have been sent to me have worked. I understand exactly why it should work like this but see no reason why not. Is there any way I have to possibly have my db column for tLetter be a type of for this to work?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Getting Checkbox to populate checked fields


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On