Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Loading the contents based on other select box usinhg query results

Posted on 2009-04-27
3
Medium Priority
?
245 Views
Last Modified: 2012-05-06
Hello Experts.

HI am using a link to load the contents of users in a table:

the users details are shown in the select box:

what i want to do is select the user from the select box and load the contents of that user in the below other select boxes as it is in database.

Like i have one query which gets username details:

<cfinvoke component="cfc.auth" method="getlogins" returnvariable="gm"/>

now i am doing this:

<tr>
        <td><div align="right">Choose user</div></td>
        <td><div align="left">
          <select name="chooseuser" id="chooseuser" tabindex="1">
                <cfoutput query="gm">
                  <option value="#id#">#username#</option>
            </cfoutput>
          </select>
        </div></td>
      </tr>

Now what i wanna do is select the user from the above select box and it should display the users details below under:

only thing i think i require is without any submit button, it should pass the query results and show the following information. That's what i think pleae tell me how this can be passed in
0
Comment
  • 2
3 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24241121
if you are on CF8 - use, for example, a CFDIV with BIND attribute, and bind it to your cfc function that returns formatted data you want to display based on selected value in your <select> list:

<tr>
  <td><div align="right">Choose user</div></td>
  <td>
  <div align="left">
  <select name="chooseuser" id="chooseuser" tabindex="1">
  <cfoutput query="gm">
    <option value="#id#">#username#</option>
  </cfoutput>
  </select>
  </div>
  </td>
</tr>
<tr>
  <td><cfdiv id="userdetails" bind="cfc:cfc.auth.getUserDetails({chooseuser@change})" bindonload="false" /></td>
</tr>

Azadi
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 24241418
i am not on coldfusion 8
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 2000 total points
ID: 24243505
use jQuery then. simplest sample code attached.

Azadi
<!--- cfm page --->
<html>
<head>
<title></title>
<script type="text/javascript" src="/path/to/jquery.js"></script>
<script type="text/javascript">
var checkJqueryGetFromRemoteCFC = function(id){
 if (id > 0) {
  $("#mydiv").html('Loading data...');
  $.get(
   'test.cfc?method=check&id='+id,
   null,
   function(data) { $("#mydiv").html(data); },
   'html'
  );
 } else {
  $("#mydiv").html("Please select some other option than 'Please select...'!");
 }
};
</script>
</head>
<body>
<select name="myselect" id="chooseuser" tabindex="1" onchange="checkJqueryGetFromRemoteCFC(this.value);">
 <option value="0" selected="selected">Please select...</option>
 <option value="1">One</option>
 <option value="2">Two</option>
 <option value="3">Three</option>
</select>
<br />
<div id="mydiv"></div>
</body>
</html>
 
<!--- test.cfc CFC --->
<cfcomponent displayname="test" output="no">
 <cffunction name="check" access="remote" returntype="string" returnformat="plain" output="no">
  <cfargument name="id" type="numeric" required="yes">
  <cfset var result = "">
  <cfsavecontent variable="result">
  <p>You requested id <cfoutput>#arguments.id#</cfoutput></p>
  </cfsavecontent>
  <cfreturn result />
 </cffunction>
</cfcomponent>

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 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