Solved

check box question

Posted on 2002-07-13
2
135 Views
Last Modified: 2013-12-24
hi experts,

<input type="checkbox" default="" name="chk">

<cfquery datasource="test" name="disp">
  select * from employee
</cfquery>


<input type="submit" value="ok" name="submit">

when i check the check box and click on ok button i want to store the name and number into details table.


how to do this.
i tried like this
<cfif chk eq 1>
<cfquery datasource="insert" name="ins">
  insert into details where username =#un# and number=#no#
</cfquery>
</cfif>

0
Comment
Question by:NASEEMA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Expert Comment

by:ndintenfass
ID: 7152500
A checkbox will only pass a value if it is checked.  You can either test for the existence of it, or define a default value.

So, if you have a form that looks like:

----------------------------------
<form action="actionPage.cfm" method="post">

<input type="checkbox" name="chk" value="1"> Check Here To Store Name and Number

<br><br>

Name: <input type="text" name="name"><br>
Number: <input type="text" name="number"><br>
<input type="submit" value="ok" name="submit">
</form>
-----------------------------------

On your action page you could do something like:

<cfif isDefined("form.chk") and form.chk is 1>
DO YOUR INSERT
</cfif>

Or,

<cfif structKeyExists(form,"chk") and form.chk is 1>
DO YOUR INSERT
</cfif>

Or,

<cfparam name="form.chk" default="0">
<cfif form.chk is 1>
DO YOUR INSERT
</cfif>



0
 
LVL 17

Accepted Solution

by:
anandkp earned 50 total points
ID: 7153476
Hi,

U could even try the foll

<input type="checkbox" value="username,no" name="chk">
[note -the vlue of chkbox is a list of username & the number - delimited by a  ","]

now when u chk for isdefined of chk on next page ie

<cfif isdefined('chk') eq 1>
 <cfquery datasource="insert" name="ins">
  insert into details where username =#ListGetat(chk,1)# and number=#ListGetat(chk,2)#
 </cfquery>
</cfif>


let me know if this helps
K'Rgds
Anand


0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question