Skip to main content
Participating Frequently
April 15, 2009
Question

Help with DB driven forms

  • April 15, 2009
  • 1 reply
  • 1425 views

Hello,

I created two select box populated by information in a SQL Database which works fine. I want to be able to have a user pick from 1 of the 2 select boxes and submit a request to pull up information from the SQL Database base on their selection. The result should be placed on a page called results.cfm which will display their choice but I'm having trouble pulling over the information. Can anyone please guide me in the right direction? I've provided the code i've got so far. Any help is appreciated.

thanks in advance,

Eynar23

PS -  i'm looking for a little guidence as I want to learn how to accomplish this on my own.

******************************************************************************

<h3>Search by Related Area:</h3>


<cfform name="selectchoice" action="results.cfm" method="post">


<cfquery name = "RelatedAreaDrop" dataSource = "CSSYS_IssueTracker">

SELECT  Value, Description

FROM CS_RelatedAreas

ORDER BY Value

</cfquery>


<cfselect name = "start_end" query = "RelatedAreaDrop" size = "1" value="Value">

</cfselect>


<BR><BR>


<h3>Search by Issue Type:</h3>



<cfquery name = "IssueTypeDrop" dataSource = "CSSYS_IssueTracker">

SELECT IssueType

FROM CS_RelatedAreas

GROUP BY IssueType

</cfquery>


<cfselect name = "start_end2" query = "IssueTypeDrop" size = "1" value="IssueType">


</cfselect>


<br><br>

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


</cfform>

    This topic has been closed for replies.

    1 reply

    April 16, 2009

    What do you mean by having trouble pulling the information over?  What does results.cfm do?  You should just be able to reference form.start_end or form.start_end2.

    eynar23Author
    Participating Frequently
    April 16, 2009

    Hi,

    I need the results.cfm page to fill in the contents of the following table based on what they select in the previous form:

    <table width="1000" border="0" cellspacing="0" cellpadding="0" class="borderedtable">

    <tr>

    <th align="center"  valign="bottom">ID </th>

    <th valign="bottom">Related Area</th>

    <th valign="bottom">Priority</th>

    <th valign="bottom">Status</th>

    <th valign="bottom">Title</th>

    <th valign="bottom">Description</th>

    <th valign="bottom">Benefits</th>

    </tr>

    <cfoutput>

    <td align="left" valign="top">#ID#</td>

    <td valign="top" align="center">#RelatedArea#</td>

    <td valign="top" align="center"><A href="sr_list_include/priority.cfm"

       onClick="return popup(this, 'notes')">#priority#</a></td>

    <td valign="top" align="center">#status#</td>

    <td valign="top">#Title#</td>

    <td valign="top">#description#</td>

    <td valign="top">#benefits#&</td>

    </cfoutput>

    </tr>

    </table>

    All this information currently exist in the the Database "CSSYS_IssueTracker". I want the user to have the ability to search by eith Related Area or Issue Type. I also made a mistake in my previous post:

    <cfquery name = "IssueTypeDrop" dataSource = "CSSYS_IssueTracker">

    SELECT IssueType

    FROM CS_RelatedAreas ArcZone_CS_SRList

    GROUP BY IssueType

    </cfquery>

    thanks

    eynar23Author
    Participating Frequently
    April 16, 2009

    OK. I think i have it figured out. I was able to populate the table & display the info for the first select box "start_end" with the code below.

    <cfquery name="choice" datasource="CSSYS_IssueTracker">

    SELECT ID, IssueType, Title, Status, StatusDesc, Priority, PriorityDesc, Description,

    OSS_SR_Benefits, RelatedAreaID, RelatedArea, RelatedAreaDesc

    FROM CS_RelatedAreas

    WHERE RelatedArea = '#form.start_end#'

    ORDER BY Priority

    </cfquery>

    Then I did another query for the second select box

    thanks for the help.