[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Passing a cfselect value as a url variable using cfpoutput to reload the page

Posted on 2003-11-19
7
Medium Priority
?
997 Views
Last Modified: 2013-12-24
HELP!  I need to reload the current page using the value from the cfselect as a url variable.

Within the cfform is the following cfselect:

<cfselect  name="ChooseWeek" style="word-spacing: 0; text-align: Left; list-style-type: disc; margin: 0" multiple = "No" >
          <cfoutput query="GetWeekEnds" >                                          
          <option>#WeeKEndDate# </option>                              
            </cfoutput>
</cfselect>

The query works fine and the cfselect loads fine.  I want the user to be abkle to select an new Week Ending Date and then reload the page using that new date as the parameter for the query that selects records.

I want to execute something like:

<A HREF="timecardenter.cfm?WeekTime= <cfoutput>#URLEncodedFormat(TimeForm1.ChooseWeek)#</cfoutput>" >Show New Week</A>

I've tried many variations of this and they all fail because I can't seem to reference the ChooseWeek value.  I've tried it within the cfform with no form identifier, outside the form with the TimeForm1 reference, etc.

Ideally it would execute when the used selects a new dat, but adding a separate button is okay too.

I'm sure I'm missing something easy.  Any ideas will be greatly appreciated.

WS
0
Comment
Question by:Waterstone
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:CFDevHead
ID: 9780268
try this
<script>

function gotosite(url){
      window.location.href=url;
      document.formURL.selectURL.blur();
}
</script>

gotosite(this.options[this.selectedIndex].value)

<cfselect  name="ChooseWeek" style="word-spacing: 0; text-align: Left; list-style-type: disc; margin: 0" multiple = "No" passthrough="onChange='gotosite(this.options[this.selectedIndex].value)'">
         <cfoutput query="GetWeekEnds" >                                   
          <option value='#WeeKEndDate#'>#WeeKEndDate# </option>                        
          </cfoutput>
</cfselect>
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 9780273
oops
here is the real script.
<script>

function gotosite(url){
     window.location.href=url;

}
</script>
0
 

Author Comment

by:Waterstone
ID: 9780548
Thanks for the reply CFDevHead,

I tried your example.

passthrough="onChange='gotosite(this.options[this.selectedIndex].value)'"

does execute gotosite but the url argument is empty.   I altered the gotosite script to include alert(url); to see the argument.

The page I'm on is entertime.cfm  It has a variable:
<cfparam name=url.WeekTime default="01/01/1900">
I want to take the value from ChooseWeek and reload the page like

entertime.cfm?ChooseWeek.value so that I can use ChooseWeek as a query parameter
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 9

Expert Comment

by:CFDevHead
ID: 9780563
So do you need anymore help?
0
 

Author Comment

by:Waterstone
ID: 9780643
Yes I do.  The url argument appears to be empty.  Is there a way to pass the value of the cfselect field as an argument to a new instance of the page.  I do it now with

<cfoutput query="GetWeekEnds" startRow = "1" maxRows = "2">
              <A HREF="timecardenter.cfm?WeekTime=#WeekEndDate#" style="text-decoration:none">#WeekEndDate# </A>&nbsp;&nbsp;&nbsp;
</cfoutput>

this is not within the form.  It displays the first two record from the query and reloas the page with the passed value as the value of the variable WeekTime.

I'd like to do the same thing with the value selected from the drop down list.

Do you know how this can be done?

Thanks
0
 
LVL 9

Accepted Solution

by:
CFDevHead earned 2000 total points
ID: 9780697
Just add the url to the value of the option.

<cfselect  name="ChooseWeek" style="word-spacing: 0; text-align: Left; list-style-type: disc; margin: 0" multiple = "No" passthrough="onChange='gotosite(this.options[this.selectedIndex].value)'">
         <cfoutput query="GetWeekEnds" >                                   
          <option value='timecardenter.cfm?WeekTime=#WeekEndDate#" '>#WeeKEndDate# </option>                        
          </cfoutput>
</cfselect>


to open the page in new change the script to

<script>

function gotosite(url){
     window.open(url);

}
</script>
0
 

Author Comment

by:Waterstone
ID: 9780820
Bingo!  

Works like a champ.  Thank you.


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

834 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