Solved

check box question

Posted on 2002-07-13
2
132 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
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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unsearchable in Google,Yahoo and Bing. 6 64
PHP in Apache server 20 102
ip / url redirect 13 73
Help with a redirect in web.config file 8 56
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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