Solved

check box question

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
remove Handler and Add Handler for one file 3 32
Forbidden errors 5 107
Firewall Speed Issue 6 60
Internal DNS Zone Issue 13 51
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now