EasyCFM.COM ColdFusion Forums / Coding Help! / Drop Down Boxes

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Drop Down Boxes -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

mindytruitt
07-06-2004 @ 5:33 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 20
Joined: Jun 2004

I am a little stuck trying to figure out how to create a drop down box so that when you click on a value it automatically transfers you to another page or refresh that page to adjust for the value that was clicked on.  

<tr>
  <td width="125" bgcolor="#CCCCFF">
    <div align="right">Fiscal Year:</div>
  </td>
  <td width="349" align="center">
    <div align="left">
    <cfset year = #URL.ID#></cfoutput>
    <select name = "FiscalYear">
    <cfoutput>
    <cfloop index="x" from="0" to="15" step="1">
    <option value=ChargeabilityReportEntry.cfm?ID=#year#>#year#
    <cfset year = year + 1>
    </option>
    </cfloop>
    </cfoutput>
    </select>
  </td>
</tr>

But when this code is runs, you have to click on submit for it to change.

Thanks
Mindy

jov17
07-06-2004 @ 6:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 76
Joined: Dec 2003

You can use javascript:

<Script language="JavaScript">
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
</SCRIPT>

<tr>
  <td width="125" bgcolor="#CCCCFF">
    <div align="right">Fiscal Year:</div>
  </td>
  <td width="349" align="center">
    <div align="left">
    <cfset year = #URL.ID#></cfoutput>
    <select name = "FiscalYear" ONCHANGE="goto(this.form)">
    <cfoutput>
    <cfloop index="x" from="0" to="15" step="1">
    <option value=ChargeabilityReportEntry.cfm?ID=#year#>#year#
    <cfset year = year + 1>
    </option>
    </cfloop>
    </cfoutput>
    </select>
  </td>
</tr>


let me know if this works for you.

Thanks

James

CJ
07-06-2004 @ 6:13 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

<select name="FiscalYear" onchange="this.form.submit();">

-CJ-
@ #coldfusion/DALNet
http://charlie.griefer.com

This message was edited by CJ on 7-6-04 @ 6:13 PM

mindytruitt
07-07-2004 @ 2:53 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 20
Joined: Jun 2004

I was able to add the code but I am now getting an error:

Error Occurred While Processing Request
Error Diagnostic Information
An error has occurred.

HTTP/1.0 404 Object Not Found

Any Ideas on what it means or referring to??



mindytruitt
07-07-2004 @ 3:41 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 20
Joined: Jun 2004

I tried to just see if I could get the drop down box to work and made its own page but It still causes the server to overrun and I have to restart.  Does anyone see a problem with this code?  


<cfquery name="charge" datasource="literature">
select *
from Users, Chargeability
WHERE Users.sales >=3 AND #URL.ID# = Chargeability.FiscalYear
Order By UserName
</cfquery>

<script language="javaScript">
<!--

function goto(form){var index=form.select.selectedIndex
if(form.select.options[index].value !="0")
{ location=form.select.options[index].value;}}
//-->
</script>

<html>
<body>
<cfoutput>
Fiscal Year:
<cfset year=#URL.ID#></cfoutput>
<select name = "FiscalYear" onchange="this.form.submit();">
<cfoutput>
<cfloop index="x" from="0" to="16" step="1">
<option value=tester.cfm?ID=#year#>#year#
<cfset year = year + 1>
</option>
</cfloop>
</cfoutput>
</select>

CJ
07-07-2004 @ 3:45 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

mindy:

i'm going to guess that your query is incorrect.

are you sure that instead of:

     AND #URL.ID# = Chargeability.FiscalYear

you didn't want:

     AND Charegeability.FiscalYear = #URL.ID#

?

-CJ-
@ #coldfusion/DALNet
http://charlie.griefer.com

CJ
07-07-2004 @ 3:50 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

mindy:

give the code below a try:

<cfquery name="charge" datasource="literature">
     SELECT *
     FROM
          users,
          chargeability
     WHERE
          Users.sales >=3 AND
          Chargeability.FiscalYear = <cfqueryparam value="#URL.ID#" cfsqltype="cf_sql_integer">
     ORDER BY
          userName
</cfquery>

<html>

<head>
     <script type="text/javascript">
          function jump(yr) {
               if (yr != "") {
                    location.href="tester.cfm?ID=" + yr;
               }
          }
     </script>
</head>

<body>

<form>
<table>
<tr>
     <td width="125" bgcolor="#ccccff">
          <div align="right">Fiscal Year:</div>
     </td>
     <td width="349" align="left">
          <cfset currentYear = URL.ID>
          <select name="fiscalYear" onchange="jump(this.options[this.selectedIndex].value);">
          <option value="">Please Select a Year</option>
          <option value=""></option>
          <cfoutput>
               <cfloop index="x" from="1" to="16" step="1">
                    <option value="#currentYear#">#currentYear#</option>
                    <cfset currentYear = currentYear + 1>
               </cfloop>
          </cfoutput>
          </select>
     </td>
</tr>
</table>
</form>

</body>
</html>


made a few changes...most notably adding a couple of blank options at the top of the <select>.  without those, your onchange() function means the user will never have the option of selecting the first year in the list.

also assumed that the SQL needed to be switched around a little (as per my previous post).

let me know if that works.



-CJ-
@ #coldfusion/DALNet
http://charlie.griefer.com

This message was edited by CJ on 7-7-04 @ 3:53 PM

mindytruitt
07-07-2004 @ 4:00 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 20
Joined: Jun 2004

I tried that and it still brought down the server.  I have access open but not to the database, would that have anything to do with it??

CJ
07-07-2004 @ 5:37 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

mindy:

can you paste the exact code for the page?  i don't see anything that should be bringing down a server.



-CJ-
@ #coldfusion/DALNet
http://charlie.griefer.com

mindytruitt
07-07-2004 @ 5:45 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 20
Joined: Jun 2004

I ended up just coping and pasting the code you had showed me and tried running that but it still has the problem.  I run the page as "Tester.cfm?ID=2004" which I assume is right but just checking.  

Thanks - Mindy

<cfquery name="charge" datasource="literature">
     SELECT *
     FROM
          users,
          chargeability
     WHERE
          Users.sales >=3 AND
          Chargeability.FiscalYear = <cfqueryparam value="#URL.ID#" cfsqltype="cf_sql_integer">
     ORDER BY
          userName
</cfquery>

<html>

<head>
     <script type="text/javascript">
          function jump(yr) {
               if (yr != "") {
                    location.href="tester.cfm?ID=" + yr;
               }
          }
     </script>
</head>

<body>

<form>
<table>
<tr>
     <td width="125" bgcolor="#ccccff">
          <div align="right">Fiscal Year:</div>
     </td>
     <td width="349" align="left">
          <cfset currentYear = URL.ID>
          <select name="fiscalYear" onchange="jump(this.options[this.selectedIndex].value);">
          <option value="">Please Select a Year</option>
          <option value=""></option>
          <cfoutput>
               <cfloop index="x" from="1" to="16" step="1">
                    <option value="#currentYear#">#currentYear#</option>
                    <cfset currentYear = currentYear + 1>
               </cfloop>
          </cfoutput>
          </select>
     </td>
</tr>
</table>
</form>

</body>
</html>





PAGE: 1 2
Sponsored By...
iOpenSoft, LLC is a Houston, Texas Advanced Technology Studio Specializing in Web Design, Web Development, iPhone App Development and Android App Development.