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:
  #1  
Old August 31st, 2006, 01:15 PM
just_life just_life is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 7 just_life User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 55 m 51 sec
Reputation Power: 0
Inserting a Check box value

The undermentioned is how my cfm file looks.when i dont check any of the checkboxes, I get a error message "Variable Q4 is undefined", but I do not get it if i leave "q9" blank, which is a textarea. I hope all of this text would'nt be smushed and incomprehensible. Please help.

<CFQUERY name="survey101" datasource="survey">
INSERT INTO SURVEY_101(OTHER,
<CFIF q4 Is Not "">
STAYED,
</CFIF>
<CFIF q9 Is Not "">
COMMENTS,
</CFIF>
)
Values('#q10#',

<CFIF q4 Is Not "">
'#q4#',
</CFIF>
<CFIF q9 Is Not "">
'#q9#',
</CFIF>
)
</CFQUERY>
<html>
<form name="survey101" action="http://www.dadadxcj.com/Survey101/survey_vj.cfm" method="post">
<label for="10.36">Other</label><br>
<input id="10.36" size="60" name="q10"><br>
<p>4. Having stayed at this property, did you (select all that apply):*</p>

<input type="checkbox" value="12" name="q4"><label for="4.12">Receive the applicable rate?</label><br>
<input type="checkbox" value="13" name="q4"><label for="4.13">Have to pay actual expenses rate?</label><br>

<p>5. What would you change (add or substract) about the website?</p>
<textarea id="9.35" name="q9" rows="5" cols="40"></textarea><br>

<input type="submit" value="Submit" name="submit">
</form>
</html>

Reply With Quote
  #2  
Old August 31st, 2006, 04:34 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,743 kiteless User rank is Second Lieutenant (5000 - 10000 Reputation Level)kiteless User rank is Second Lieutenant (5000 - 10000 Reputation Level)kiteless User rank is Second Lieutenant (5000 - 10000 Reputation Level)kiteless User rank is Second Lieutenant (5000 - 10000 Reputation Level)kiteless User rank is Second Lieutenant (5000 - 10000 Reputation Level)kiteless User rank is Second Lieutenant (5000 - 10000 Reputation Level)kiteless User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 21 h 7 m 14 sec
Reputation Power: 62
A couple of things. First, when in doubt, dump it. Use cfdump to output the form scope and see what is there. HTML form checkboxes are not sent if they are not checked. So if the user doesn't check the check box, there will be no form variable for that field. I would use cfparam to set a default value of false if the variable isn't present in the form scope.

And speaking of form scope, if your query is using variables in the form scope, then prefix them with "form." Always scope anything not in the local variables scope for clarity and performance. If you don't scope, CF has to go look up the chain of scopes to try and find a match. This hurts performance but more importantly, if you have the same variable in multiple scopes it is easy to end up with the wrong one!

Hope all this helps.
__________________
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
  #3  
Old September 8th, 2006, 10:24 AM
just_life just_life is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 7 just_life User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 55 m 51 sec
Reputation Power: 0
Smile yes..cfparam worked

Thank You..that was so simple and it worked.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Inserting a Check box value


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
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT