#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    58
    Rep Power
    4

    Passing two form variables in a single URL


    I'm running the following form.
    Code:
    // Parameters Defined
    
        <cfparam name="form.startdate" default="#DateFormat(dateAdd('d',-40,now()), 'yyyy-mm-dd')#">
        <cfparam name="form.enddate" default="#DateFormat(dateAdd('d',-1,now()), 'yyyy-mm-dd')#">
    
    
    
        <cfform format="HTML" action="Download.cfm" method="get">
        
        
        <cfformgroup type="horizontal">
        
          <cfinput type="dateField" name="startdate" label="Start Date" width="100" value="#form.startdate#">
          <cfinput type="dateField" name="enddate" label="End Date" width="100" value="#form.enddate#">
          <cfinput name="submitApply" type="submit" value = "Apply">
          
        <!---   <cfset url = "http://abc.xyz.com/<username>/Testing/Testing/Download.cfm"> --->
          <cfinput type="button" name="download" value="Download" onclick="window.location.href='Download.cfm?path=http://abc.xyz.com/<username>/Testing/Testing/Download.cfm'"> 
        
        </cfformgroup>
        
        
        
        </cfform>

    I want to pass the value of #form.startdate# and #form.enddate# from the current page to the page "Download.cfm". Hence I did the following change in the above URL of onclick event:

    Code:
    onclick="window.location.href='Download.cfm?startdate=#form.startdate#?enddate=#form.enddate#path=http://abc.xyz.com/<username>/Testing/Testing/Download.cfm'"
    But it didn't work. Could anyone please tell me what's wrong with my above code?
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    "It didn't work" isn't enough information.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    58
    Rep Power
    4
    Originally Posted by kiteless
    "It didn't work" isn't enough information.

    I'm running the following form inside abc.cfm.

    // Parameters Defined


    Code:
             <cfparam name="form.startdate" default="#DateFormat(dateAdd('d',-40,now()), 'yyyy-mm-dd')#">
        <cfparam name="form.enddate" default="#DateFormat(dateAdd('d',-1,now()), 'yyyy-mm-dd')#">
        <cfparam name="form.selectdate" default="#dateformat(now(), 'mm/dd/yyyy')#">
        
        
        
           
        
             <cfform format="HTML" action="datedownload.cfm" method="get" >
            
            
            <cfformgroup type="horizontal">
            
              <cfinput type="dateField" name="startdate"  width="100" value="#form.startdate#">
              <cfinput type="dateField" name="enddate"  width="100" value="#form.enddate#">
              <cfinput name="submitApply" type="submit" value = "Apply">
                  
                <cfinput type="button" name="download" value="Download" onclick="window.location.href='datedownload.cfm?startdate=#form.startdate#&enddate=#form.enddate#path=http://abc.xyz.com/username/July30/datedownload.cfm'"> 
                
            
            
                
                </cfformgroup>
                
                
                
                </cfform>
    Error I'm getting:





    Element STARTDATE is undefined in FORM.

    Code:
      The error occurred in C:\abc.xyz\username\July30\datedownload.cfm: line 9
        
        7 : 
        8 : 
        9 : <cfdump var = "#form.startdate#">
        10 : <body>
        11 : </body>



    As clear from my form code defined above, I have already defined `name=startdate`. I'm wondering what is wrong?
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,286
    Rep Power
    968
    The form scope is only populated during a POST request. So first, you're doing a GET. And second, you can't use the form scope in a click handler like that, because the form hasn't been submitted yet.

    Is there some reason you're not just doing a POST with a normal submit button?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    58
    Rep Power
    4
    Originally Posted by kiteless
    The form scope is only populated during a POST request. So first, you're doing a GET. And second, you can't use the form scope in a click handler like that, because the form hasn't been submitted yet.

    Is there some reason you're not just doing a POST with a normal submit button?
    There is no specific reason but I got this resolved by removing the method and action attribute from the cfform tag.

IMN logo majestic logo threadwatch logo seochat tools logo