Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
bforce #1
Need Help Processing Checkbox Form Elements
What I'm doing: I'm pulling news releases form an SQL DB that have a status
of 0. I'm using CFOUTPUT QUERY to output all the records into a table. Each
record result has its own checkbox that if isDefined onSubmit will set the
news release status to 1. In effect activating the record. Now since I'm
using an cfoutput query, I have to increment the checkbox names using a
counter, ie.. nr1, nr2, nr3 etc...
My question: How can I dynamically evaluate the checkboxes to see if they
are defined and update my DB? I need it to be dynamic because the number of
news releases needing activation will change constantly.
The following is how I'm creating my checkboxes:
<cfset checkBoxIncrement = 1>
<cfoutput query="getFiles">
<cfset checkBoxIncrement = checkBoxIncrement + 1>
<cfinput type="checkbox" name="nr#checkboxincrement#" value="#getFiles.id#">
</cfoutput>
My update query should look something like this:
<cfif isDefined("form.submit")>
<cfquery DATASOURCE="myDS" name="SetNRStatus">
UPDATE newsreleases
set status = 1
where (ID = '#????#') <!---How can I pull all the ID's that are checked?--->
</cfquery>
</cfif>
Thanks.
bforce Guest
-
Form Processing Applications
I have not had much experience with forms processing, but need to build one for a site. I saw a link to Kmita-mail (http://www1.kmita-mail.com/)... -
Processing multiple checkbox responses
I'm now at my wits end on this- A question on a test has 2 correct answers, "ans_b" and "ans_c". In the DB, the "ans_correct" field contains... -
Html form processing
I have been trying this for a few days now. I seem to get parts of it, but I can't get the full scenario to work. I have a page that has an email... -
Form Processing
Hi, I am designing a basic email form using Dreamweaver and the checks are successful. Does Dreamweaver have any functionality to enable me to... -
More form processing
Hey folks, I need some of your expertiese again. I am creating a survey form and need some help gathering the results of a question that has... -
Kronin555 #2
Re: Need Help Processing Checkbox Form Elements
Here's a solution that might be much simpler.
When you have multiple checkboxes on a form, all with the same name, then the
submitted value will be all the values of the checked checkboxes.
ie:
<form name="testing">
News Release 3 <input type="checkbox" name="newsreleaseactivate" value="3"><br>
News Release 5 <input type="checkbox" name="newsreleaseactivate" value="5"><br>
News Release 12 <input type="checkbox" name="newsreleaseactivate"
value="12"><br>
News Release 23 <input type="checkbox" name="newsreleaseactivate"
value="23"><br>
<input type="submit" name="submit" value="submit">
</form>
If you check News Release 3 and News Release 12 and submit, the value of
FORM.newsreleaseactivate will be "3,12"
Then all you need to do is change your query from:
where (ID = '#????#') <!---How can I pull all the ID's that are checked?--->
to:
where id in (#FORM.newsreleaseactivate#)
Kronin555 Guest
-
bforce #3
Re: Need Help Processing Checkbox Form Elements
Worked like a charm. Thanks.
"Kronin555" <webforumsuser@macromedia.com> wrote in message
news:d4rggv$l4e$1@forums.macromedia.com...> Here's a solution that might be much simpler.
>
> When you have multiple checkboxes on a form, all with the same name, then
> the
> submitted value will be all the values of the checked checkboxes.
>
> ie:
>
> <form name="testing">
> News Release 3 <input type="checkbox" name="newsreleaseactivate"
> value="3"><br>
> News Release 5 <input type="checkbox" name="newsreleaseactivate"
> value="5"><br>
> News Release 12 <input type="checkbox" name="newsreleaseactivate"
> value="12"><br>
> News Release 23 <input type="checkbox" name="newsreleaseactivate"
> value="23"><br>
> <input type="submit" name="submit" value="submit">
> </form>
>
> If you check News Release 3 and News Release 12 and submit, the value of
> FORM.newsreleaseactivate will be "3,12"
>
> Then all you need to do is change your query from:
> where (ID = '#????#') <!---How can I pull all the ID's that are
> checked?--->
> to:
> where id in (#FORM.newsreleaseactivate#)
>
bforce Guest
-
bforce #4
Re: Need Help Processing Checkbox Form Elements
Oops! I started playing around with this and realized that the checkboxes
are always going to be defined because they will always be pulling an id
from the DB. So even if I do not check the boxes and submit the form, the
query runs and updates the status field. Not what I want to have happen. I'm
going to have to go another route. Perhaps a list menu.
<cfif isDefined("form.submit")>
<cfif isDefined("form.nr")>
<cfquery DATASOURCE="myDataSource" name="myQuery">
UPDATE newsreleases
set status = 1,
pdfPath = 'PDFDocs/#getFiles.PDFname#',
image = 'images/#getFiles.imagename#'
where id in (#FORM.nr#)
</cfquery>
"bforce" <bforce@poultryegg.org> wrote in message
news:d4rdqs$hbe$1@forums.macromedia.com...> What I'm doing: I'm pulling news releases form an SQL DB that have a
> status of 0. I'm using CFOUTPUT QUERY to output all the records into a
> table. Each record result has its own checkbox that if isDefined onSubmit
> will set the news release status to 1. In effect activating the record.
> Now since I'm using an cfoutput query, I have to increment the checkbox
> names using a counter, ie.. nr1, nr2, nr3 etc...
>
> My question: How can I dynamically evaluate the checkboxes to see if they
> are defined and update my DB? I need it to be dynamic because the number
> of news releases needing activation will change constantly.
>
> The following is how I'm creating my checkboxes:
>
> <cfset checkBoxIncrement = 1>
> <cfoutput query="getFiles">
> <cfset checkBoxIncrement = checkBoxIncrement + 1>
> <cfinput type="checkbox" name="nr#checkboxincrement#"
> value="#getFiles.id#">
> </cfoutput>
>
> My update query should look something like this:
> <cfif isDefined("form.submit")>
> <cfquery DATASOURCE="myDS" name="SetNRStatus">
> UPDATE newsreleases
> set status = 1
> where (ID = '#????#') <!---How can I pull all the ID's that are
> checked?--->
> </cfquery>
> </cfif>
>
> Thanks.
>
bforce Guest



Reply With Quote

