Solved

Data population in Cold Fusion

Posted on 2014-02-09
3
218 Views
Last Modified: 2014-02-27
Category DropdownHi,
  I have a CFM page where I list Category along with CategoryID in the drop down.
  I like to be able to populate Category ID (in parenthesis) in the Category ID field when user selects the category from the drop-down menu.
  For example, when the user selects "Picture Frames", then I want the page to populate 23 automatically into Category ID field as seen in the screenshot above.
  Here are the codes in my CFM page

<CFQUERY NAME="GetCategory" datasource="DNSName" cachedWithin="#CreateTimeSpan(0,1,0,0)#">
      SELECT      *
         FROM         Category
      ORDER BY Category
</CFQUERY>

    <TR bgcolor="B5D083">
        <TD>
           Category ID:
        </TD>
        <TD>
      <CFINPUT TYPE="text" NAME="CategoryID" SIZE=3 MAXLENGTH=3> Category Lookup:
                  <SELECT NAME="CategoryID">
                    <OPTION VALUE="0"></OPTION>
                  <CFOUTPUT query="GetCategory">
                  <OPTION VALUE="#ID#">#Category#/(#ID#)</OPTION>
                  </CFOUTPUT>
                  </SELECT>        </TD>
    </TR>
0
Comment
Question by:sglee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Accepted Solution

by:
erikTsomik earned 158 total points
ID: 39846396
I think the best approach will be using jquery to create on change event

$("#CategoryID).change(function(){
   $("#CategoryID").val($(this).val());
})

or something like this. Make sure that the id is spelled correctly. Because jquery is a case sensitive
0
 

Author Comment

by:sglee
ID: 39846436
@erikTsomik
Where exactly I need to insert the code above?
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 157 total points
ID: 39848268
It's JQuery code, so put it inside document.ready. But for Erik's example to work, both fields must have an "ID".  (Also fixed a small typo).  To avoid confusion, use different id's like in the <form> below:

<script type"text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
      $(document).ready(function() {
            $("#CategoryID").change(function() {
                  $("#SelectedCategoryID").val($(this).val());
            });
            
      });
</script>
<form>
      Selected Category <input type="text" id="SelectedCategoryID" name="SelectedCategoryID"><br>
      All Categories <select id="CategoryID" name="CategoryID">
      <cfoutput query="getCategory">
            <option value="#ID#">#Category# (#ID#)</option>
      </cfoutput>
      </select>
</form>
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

742 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