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 January 22nd, 2005, 06:35 PM
mk_senthil mk_senthil is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 45 mk_senthil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 9 m 49 sec
Reputation Power: 4
passing checkbox values to the action page

Hi All, I need to solve this issue..

I'm getting the values for my checkbox in a loop and if the user checks the "select all"checkbox all the data should be deleted from the table and if the user checks only one checkbox I need to delete only the particular selected value from the table..

my problem really is when I passing the values to the action page only the first value(chk_box_1) is being passed and I'm getting an error "chk_box_2".... is not defined.

Any clue?

Reply With Quote
  #2  
Old January 22nd, 2005, 10:28 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,913 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 12 h 24 m 34 sec
Reputation Power: 1018
checkboxes that aren't checked aren't even passed over from the browser when the form is submitted

that's the way they work

therefore you must check to see if the checkbox is present, i.e. exists, before you use it

some people like to use IsDefined but i use CFPARAM
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old January 22nd, 2005, 10:31 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 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 15 h 22 m 41 sec
Reputation Power: 53
If there is a chance that one of the checkboxes won't be checked you have to test for it's existence on the action page. Remember that HTML forms don't pass in any unchecked check boxes.

You can check for it's existence like this:

<cfif structKeyExists( form, 'myCheckboxField' )>
...the field is there...
</cfif>

Or if you prefer you can automatically create it and set it to a default value if it doesn't exist with <cfparam>.
__________________
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
  #4  
Old January 23rd, 2005, 05:19 PM
mk_senthil mk_senthil is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 45 mk_senthil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 9 m 49 sec
Reputation Power: 4
please check the code

Hi All

thanks for the response.Please review the code given below which I'm using and give me a solution to solve the issue.

This is what I'm trying to do in the form page.

<---javascript to select check all check box--->

function selectedList(src)
{
if(document.frm_workorder.deleteall.checked)
set(1);
else
set(0);
}

function set(setOrUnset)
{
for (var i = 1; i <= document.frm_workorder.Total_check_boxes.value; i++)
{
var object = eval("document.frm_workorder.chk_proj_" + i);
if(setOrUnset == 1)
object.checked = true;
else
object.checked = false;
}
}

function deleteapprover()
{
if (deleteapprover.arguments.length == 0)
{
var objectchecked = false;
for (var i = 1; i <= document.frm_workorder.Total_check_boxes.value; i++)
{
var object = eval("document.frm_workorder.chk_proj_" + i);
if(object.checked)
{
objectchecked = true;
break;
}
}
if(!(objectchecked))
{
alert("Please select the checkbox first to delete a record");
return;
}
else
//submit
document.frm_workorder.action = "add_approveraction1.cfm?mode=delete";
document.frm_workorder.submit();
}
else
{
if(confirm("This Approver will be deleted"))
{
document.frm_workorder.deleteall.checked = true;
set('1');
document.frm_workorder.action = "add_approveraction1.cfm?mode=delete";
document.frm_workorder.submit();
}
}
}
<--end of java script>


<--to select all the check boxes to delete all the records in one time-->

<a href="javascript:deleteapprover();" class="sm_text_small"> Delete </a>

<form name="frm_workorder" action="post">
<TD align="left" valign="middle" class="sm_text_small" nowrap width="50">Select All<BR><a href="" class="small_helpers"><input type="checkbox" name="deleteall" value="" align="middle" onclick="selectedList(this);"></a></TD>

<--I could able to select and deselect the check boxes at his point-->


<cfset chk_box_counter = 0>
<cfset currentrow ="">
<cfloop query = "getmgrntfy">
<cfset chk_box_counter = chk_box_counter + 1>
<TD align="left" valign="middle" class="Text">
<input type="checkbox" value="#ntfy_em_id#" name="chk_proj_#chk_box_counter#" align="middle"></TD>
</cfloop>
</form>

Action page...(add_approveraction1.cfm)

<cfif isdefined("form.mode")>
<cfif mode eq "delete">
<cfloop index="count" from=1 to="#Form.Total_check_boxes#">
<cfset chkproj = "form.chk_proj_#Evaluate(count)#">
<cfset chkproj = "#Evaluate(chkproj)#">
<cfquery name="deleteusernotify" datasource="#DBName#">
delete
from un
where un.NTFY_EM_ID = '#chkproj#'
</cfquery>
</cfloop>
</cfif>
</cfif>

<--I'm getting an error while submitting after checking only one check box

Variable form.chk_proj_2 is undefined.

-->

Any clue.

But I can able to delete all the records If I checked select all check box...

Thanks..

Reply With Quote
  #5  
Old January 23rd, 2005, 05:38 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 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 15 h 22 m 41 sec
Reputation Power: 53
It sounds like there is a problem in your Javascript somewhere. That's probably where you need to debug. However you do it you should still provide server-side validation for missing fields becuase it is simple to turn off Javascript.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > passing checkbox values to the action page


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