469,292 Members | 1,325 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,292 developers. It's quick & easy.

Passing values to page

219 100+
I'm trying to pass a date/time value to a page so I can refresh the page based on the date/time selected by the user.

I'm using client variables for now, but I have to have the form at the bottom of the page so that when I hit the refresh button the date/time is used.

Is there a way to pass the value in the URL?

Expand|Select|Wrap|Line Numbers
  1.     <form method="post" action="BigPic_dt_v2.cfm?refDT=#PDT#">
  2.     </cfoutput>
  3.     <SELECT name="ed_dt">
  4.             <option>Select a Date/Time</option>
  5.             <cfoutput query="getEDV2_dt">
  6.                     <cfset ed_date=#DateFormat(date,"mm-dd-yy")#>
  7.                     <cfset ed_time=#TimeFormat(time,"HH:mm")#>
  8.                     <cfset DT=#ed_date# & ' ' & #ed_time#>
  9.             <option>#DT#</option>
  10.             <cfset #PDT# = #ed_dt#>
  11.     </cfoutput>
  12.     </SELECT>
  13.     <input type="submit" value="Refresh">
  14.     <cfif isDefined("ed_dt")>
  15.         <cfset #CLIENT.ED_Date_Time# = #ed_dt#>
  16.     </cfif>
  17.     <cfoutput>PDT = #PDT#</cfoutput>
  18.     </form>
  19.  
I'm trying to pass the PDT value, but it doesn't get set until after the Refresh button has been pressed. Is there a way to read the value out before the refresh is pressed?
Sep 27 '07 #1
9 6333
acoder
16,027 Expert Mod 8TB
You can use JavaScript to read the value before refresh is pressed.

If you want to pass the value in the URL, use GET instead of POST as the form method.
Sep 28 '07 #2
dmorand
219 100+
You can use JavaScript to read the value before refresh is pressed.

If you want to pass the value in the URL, use GET instead of POST as the form method.
javascript is really the only option I have to pass the value from the select list?
I just want to pass the key value in the url for the item the user selects.

Expand|Select|Wrap|Line Numbers
  1. <cfoutput>
  2.     <form method="post" action="systemMaint.cfm?sysID=#form.system#">
  3. </cfoutput>
  4.     <SELECT name="system">
  5.             <option>Select a System</option>
  6.             <cfoutput query="getSystems">
  7.                 <option>#name#</option>
  8.             </cfoutput>
  9.         </SELECT>
  10.     <input type="submit" name="Edit" value="Edit">
  11.     <input type="submit" name="Delete" value="Delete">
  12.     </form>
  13.  
Sep 28 '07 #3
acoder
16,027 Expert Mod 8TB
In that case, use "get" as the form method instead of "post".

On the action page, use "url.variable" to retrieve the values.
Sep 28 '07 #4
dmorand
219 100+
In that case, use "get" as the form method instead of "post".

On the action page, use "url.variable" to retrieve the values.
Ok lets see if I can pick your brain once again.

I have a list which contains the names from a table, but I need to pass the key value to a page, not the entry which is listed in the list. The option I came up with is to place the key value into the select list with the name and then parse out the key in the javascript. I'm assuming there's a better way to do this right?

The value I want to pass is the #sysID#, but I'd rather not have it displayed in the dropdown menu.

Expand|Select|Wrap|Line Numbers
  1. <cfoutput>
  2.   <form name="selectSys" method="get" action="systemMaint.cfm?sysID=14">
  3. </cfoutput>
  4.     <SELECT name="system" onChange="readValue()">
  5.             <option>Select a System</option>
  6.             <cfoutput query="getSystems">
  7.                 <option>#sysID# - #name#</option>
  8.             </cfoutput>
  9.     </SELECT>
  10.     <input type="submit" name="Edit" value="Edit">
  11.     <input type="submit" name="Delete" value="Delete">
  12.     <input type="text" name="systemID">
  13. </form>
  14.  
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.  
  3. //window.location.href=window.location.href
  4.  
  5. function readValue(){
  6.     var n = selectSys.system.selectedIndex; //get selected index value
  7.     var val = selectSys.system[n].text; //get selected value
  8.     var temp=new Array();//split the value up by character
  9.     temp=val.split(' ');
  10.     alert(temp[0] + ' ' + temp[1]);
  11.     selectSys.sysID.value=temp[0];
  12. }
  13. </script>
  14.  
Sep 28 '07 #5
ak1dnar
1,584 Expert 1GB
Heya check this out:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">// ALWAYS USE LIKE THIS
  4. function readValue(value){
  5. alert(value)//JUST TO PRINT
  6. }
  7. </script>
  8. </head>
  9.  
  10. <body>
  11. <!--Only systemMaint.cfm is enough for pass the selcted parameters when deal with GET  -->
  12. <form name="selectSys" method="get" action="systemMaint.cfm">
  13. <!--Sorry ! I removed some <TAGS> -->
  14. <SELECT name="system" onChange="readValue(this.value)">
  15. <option>Select a System</option>
  16.  
  17. <option value="1001">Name for id 1001</option>
  18. <option value="1002">Name for id 1002</option>
  19. <option value="1003">Name for id 1003</option>
  20.  
  21. </SELECT>
  22. <input type="submit" name="Edit" value="Edit">
  23. <input type="submit" name="Delete" value="Delete">
  24. <input type="text" name="systemID">
  25. </form>
  26. </body>
  27. </html>
  28.  
  29.  
Sep 29 '07 #6
dmorand
219 100+
Heya check this out:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">// ALWAYS USE LIKE THIS
  4. function readValue(value){
  5. alert(value)//JUST TO PRINT
  6. }
  7. </script>
  8. </head>
  9.  
  10. <body>
  11. <!--Only systemMaint.cfm is enough for pass the selcted parameters when deal with GET  -->
  12. <form name="selectSys" method="get" action="systemMaint.cfm">
  13. <!--Sorry ! I removed some <TAGS> -->
  14. <SELECT name="system" onChange="readValue(this.value)">
  15. <option>Select a System</option>
  16.  
  17. <option value="1001">Name for id 1001</option>
  18. <option value="1002">Name for id 1002</option>
  19. <option value="1003">Name for id 1003</option>
  20.  
  21. </SELECT>
  22. <input type="submit" name="Edit" value="Edit">
  23. <input type="submit" name="Delete" value="Delete">
  24. <input type="text" name="systemID">
  25. </form>
  26. </body>
  27. </html>
  28.  
  29.  
I need to have #name# in my option from my query though. what are those options going to do "Name for id 1003"? Was that just an example you were showing me?
Sep 29 '07 #7
dmorand
219 100+
I need to have #name# in my option from my query though. what are those options going to do "Name for id 1003"? Was that just an example you were showing me?
O Ok, I get it now. i'm a moron once again
Sep 29 '07 #8
ak1dnar
1,584 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <option value="real_value_goes_here">display_value_goes_here</option>
  2.  
It's just an example,Thanks!
Sep 29 '07 #9
dmorand
219 100+
Expand|Select|Wrap|Line Numbers
  1. <option value="real_value_goes_here">display_value_goes_here</option>
  2.  
It's just an example,Thanks!
Yeah I realized that after. I think it's just that my brain doesn't work on the weekends, lol.
Sep 30 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Paul | last post: by
1 post views Thread by Paul | last post: by
2 posts views Thread by Gordon Hudson | last post: by
1 post views Thread by Russell | last post: by
1 post views Thread by olduncleamos | last post: by
2 posts views Thread by Ganesh | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.