Solved

check box question

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running Guacamole on port 80 5 212
IIS Site Configuration Copy 2 76
Apache SSL and mod_rewrite not working 8 156
AWS New EC2 Instance and EBS Storage 2 78
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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