在ColdFusion表单操作中将变量值添加到URL的末尾

时间:2017-05-15 17:24:06

标签: coldfusion

我试图在ColdFusion中提交表单后,在确认页面中尝试将变量值添加到URL的末尾。我可以使用典型链接添加变量:

<a href="confirmOrder-solar.cfm?provider=#provider#">

但是如果我尝试在表单操作中执行相同的操作,则值不会显示在URL中:

            <cfif getOffer.RecordCount GT 0>

        <form method="post" action="confirmOrder-solar.cfm?provider=#provider#" id="signupForm">

        <p class="red small">Fields marked with a * are required.</p>
        <div class="panelheader">Your Selected Plan</div>
        <div class="panelcontent">
            <cfoutput query="getOffer">
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td class="formfieldlabel" width="180">Rate:</td>
                <td class="normal" style="vertical-align:middle;">#rate#&cent; per kWh</td>
            </tr>
            <tr>
                <td class="formfieldlabel">Term:</td>
                <td class="normal" style="vertical-align:middle;">#term# Months</td>
            </tr>
            <tr>
                <td class="formfieldlabel">Plan Type:</td>
                <td class="normal" style="vertical-align:middle;">Fixed-Rate Plan</td>
            </tr>
            <tr>
                <td class="formfieldlabel">Documents:</td>
                <td class="normal" style="vertical-align:middle;">
                    <cfif offerType EQ "residential">
                        <cfswitch expression="#cancelTerms#">
                            <cfcase value="5mo">&##8226; <a href="../assets/docs/#getProvider.cancelDoc_5mo#" target="_blank">Terms & Conditions</a></cfcase>
                            <cfcase value="10mo">&##8226; <a href="../assets/docs/#getProvider.cancelDoc_10mo#" target="_blank">Terms & Conditions</a></cfcase>
                            <cfcase value="99fl">&##8226; <a href="../assets/docs/#getProvider.cancelDoc_99fl#" target="_blank">Terms & Conditions</a></cfcase>
                            <cfcase value="199fl">&##8226; <a href="../assets/docs/#getProvider.cancelDoc_199fl#" target="_blank">Terms & Conditions</a></cfcase>
                        </cfswitch>
                    <br />
                    <cfelseif offerType EQ "smallcommercial">
                    &##8226; <a href="../assets/docs/smallCommercialContactBlank.pdf" target="_blank">Terms & Conditions</a><br />
                    </cfif>
                    &##8226; <a href="../assets/docs/environmentalDisclosure.pdf" target="_blank">Environmental Disclosure</a><br/>
                    &##8226; <a href="http://testggg.com/wordpress/privacy-policy/" target="_blank">Privacy Policy</a>
                </td>
            </tr>
            <tr>
                <td class="formfieldlabel">Contract Start:</td>
                <td class="normal" style="vertical-align:middle;">
                <cfif Day(now()) LTE 15>
                    <select name="contractStart" id="contractStart">
                        <option value="#Month(DateAdd('m', 0, now()))#/1/#Year(DateAdd('m', 0, now()))#">Immediate</option>
                        <option value="#Month(DateAdd('m', 1, now()))#/1/#Year(DateAdd('m', 1, now()))#">#DateFormat(DateAdd("m", 1, now()), "mmm.")# #Year(DateAdd("m", 1, now()))#</option>
                        <option value="#Month(DateAdd('m', 2, now()))#/1/#Year(DateAdd('m', 2, now()))#">#DateFormat(DateAdd("m", 2, now()), "mmm.")# #Year(DateAdd("m", 2, now()))#</option>
                    </select>
                <cfelse>
                    <select name="contractStart" id="contractStart">
                        <option value="#Month(DateAdd('m', 1, now()))#/1/#Year(DateAdd('m', 1, now()))#">Immediate</option>
                        <option value="#Month(DateAdd('m', 2, now()))#/1/#Year(DateAdd('m', 2, now()))#">#DateFormat(DateAdd("m", 2, now()), "mmm.")# #Year(DateAdd("m", 2, now()))#</option>
                        <option value="#Month(DateAdd('m', 3, now()))#/1/#Year(DateAdd('m', 3, now()))#">#DateFormat(DateAdd("m", 3, now()), "mmm.")# #Year(DateAdd("m", 3, now()))#</option>
                    </select>
                </cfif>
                </td>
            </tr>
            </table>
            </cfoutput>
        </div>
        <cfoutput>
        <div class="panelheader">Personal Information</div>
        <div class="panelcontent">
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
              <!---
              <tr>
                <td class="formfieldlabel" width="180">Company Name:</td>
                <td><input type="text" name="companyName" id="companyName" style="width:240px;"></td>
                <td>&nbsp;</td>
              </tr>
              --->
              <input type="hidden" name="companyName" id="companyName">
              <tr>
                <td class="formfieldlabel" width="180">First Name: <span class="red small">*</span></td>
                <td><input type="text" name="fname" id="fname" style="width:240px;" value="#getCustomer.fname#"></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td class="formfieldlabel">Last Name: <span class="red small">*</span></td>
                <td><input type="text" name="lname" id="lname" style="width:240px;" value="#getCustomer.lname#"></td>
                <td rowspan="3" width="320" valign="bottom"><cfif getOffer.showReferral EQ "Y"><span class="small"><strong>Were you referred by a friend? Enter their email address here:</strong></span><br /><input type="text" name="referral" id="referral" style="width:240px;"><cfelse><input type="hidden" name="referral" id="referral"></cfif></td>
              </tr>
              <tr>
                <td class="formfieldlabel">Email Address: <span class="red small">*</span></td>
                <td><input type="text" name="email" id="email" style="width:240px;" value="#getCustomer.email#" <cfif session.renewal EQ "Y"></cfif>></td>
              </tr>
              <tr>
                <td class="formfieldlabel">Confirm Email: <span class="red small">*</span></td>
                <td><input type="text" name="email_confirm" id="email_confirm" style="width:240px;" value="#getCustomer.email#" <cfif session.renewal EQ "Y"></cfif>></td>
              </tr>
              <!---
              <tr>
                <td class="formfieldlabel" valign="top">Password:</td>
                <td><input type="password" name="password" id="password" style="width:240px;" <cfif getCustomer.password NEQ "">value="#Decrypt(getCustomer.password, application.encKey, "AES")#"</cfif>><br /><span class="small">If you'd like to establish an account<br />on test, please enter a password.</span></td>
              </tr>
              --->
              <input type="hidden" name="password" id="password" value="" />
            </table>
        </div>
        <div class="panelheader">Service Address</div>
        <div class="panelcontent">
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td class="formfieldlabel" width="180">Address: <span class="red small">*</span></td>
                <td><input type="text" name="serviceAddress1" id="serviceAddress1" style="width:240px;" value="#getCustomer.serviceAddress1#"></td>
              </tr>
              <tr>
                <td class="formfieldlabel">Address (cont.):</td>
                <td><input type="text" name="serviceAddress2" id="serviceAddress2" style="width:240px;" value="#getCustomer.serviceAddress2#"></td>
              </tr>
              <tr>
                <td class="formfieldlabel">City: <span class="red small">*</span></td>
                <td style="vertical-align:middle;">
                    <select name="serviceCitySelect" id="serviceCitySelect" style="width:240px;" onchange="setServiceCity();"><option value=""></option><cfloop list="#getZipCities#" index="city" delimiters=","><option value="#city#" <cfif getCustomer.serviceCity EQ city>selected</cfif>>#city#</option></cfloop><option value="other">Other...</option></select>
                    <br /><input type="text" name="serviceCityText" id="serviceCityText" style="width:240px;" onblur="setServiceCity();" />
                    <input type="hidden" name="serviceCity" id="serviceCity" value="#getCustomer.serviceCity#" />
                </td>
              </tr>
              <tr>
                <td class="formfieldlabel">State: <span class="red small">*</span></td>
                <td style="vertical-align:middle;"><select name="serviceState" id="serviceState" style="width:240px;"><cfloop query="getStates"><option value="#stateCode#" <cfif stateCode EQ application.defaultState OR stateCode EQ getCustomer.serviceState>selected</cfif>>#stateName#</option></cfloop></select></td>
              </tr>
              <tr>
                <td class="formfieldlabel">Zip Code: <span class="red small">*</span></td>
                <td><input type="text" name="dispServiceZip" id="dispServiceZip" value="#session.zipcode#" disabled="disabled" style="width:240px;"></td>
                <input type="hidden" name="serviceZip" id="serviceZip" value="#session.zipcode#">
              </tr>
              <tr>
                <td class="formfieldlabel">Phone: <span class="red small">*</span></td>
                <td><input type="text" name="phone" id="phone" style="width:240px;" value="#getCustomer.phone#"></td>
              </tr>
              <tr>
                <td class="formfieldlabel">Mobile Phone:</td>
                <td><input type="text" name="mobilePhone" id="mobilePhone" style="width:240px;" value="#getCustomer.mobilePhone#"></td>
              </tr>
              <cfif getProvider.useSDI EQ "Y">
              <tr>
                <td class="formfieldlabel">#getProvider.userAcctLabel#: <span class="red small">*</span></td>
                <td>
                    <input type="text" name="sdi1" id="sdi1" value="<cfloop query="getProvider">#sdiPrefix#</cfloop>" maxlength="9" style="width:117px;" readonly="readonly" />
                    <input type="text" name="sdi2" id="sdi2" style="width:110px;" value="#RIGHT(getCustomer.sdi, 8)#" maxlength="8" onBlur="setFullSDI(this.value);"> 
                    <a rel="../assets/images/#getProvider.findAcctNumImage#" href="javascript:return(null);" class="sampleBill" title="How to Locate Your #getProvider.userAcctLabel#:">Where's This?</a><br /><span class="small">Your SDI is tied to your current provider. If the first 9 digits of 
                    your SDI does not match what is shown here, please <a href="../newcustomer.cfm?action=reset">start the process over</a> and choose your correct provider. If you have further problems, please call (855) 322-7448.</span>
                </td>
              </tr>
              <tr>
                <td class="formfieldlabel">Confirm Your #getProvider.userAcctLabel#: <span class="red small">*</span></td>
                <td>
                    <input type="text" name="sdiConfirm" id="sdiConfirm" style="width:240px;" value="#getCustomer.sdi#" maxlength="17"> 
                    <br /><span class="small">Please re-enter your full #getProvider.userAcctLabel# number.</span>
                    <input type="hidden" name="fullSDI" id="fullSDI" value="" />
                </td>
              </tr>
              <cfelse>
              <tr>
                <td class="formfieldlabel">#getProvider.userAcctLabel#: <span class="red small">*</span></td>
                <td>
                    <input type="text" name="sdi1" id="sdi1" value="#getCustomer.sdi#" maxlength="50" style="width:240px;">
                    <input type="hidden" name="sdi2" id="sdi2" value="">
                    <cfif getProvider.findAcctNumImage NEQ "">
                    <a rel="../assets/images/#getProvider.findAcctNumImage#" href="javascript:return(null);" class="sampleBill" title="How to Locate Your #getProvider.userAcctLabel#:">Where's This?</a>
                    </cfif>
                </td>
              </tr>                  
              <tr>
                <td class="formfieldlabel">Confirm Your #getProvider.userAcctLabel#: <span class="red small">*</span></td>
                <td>
                    <input type="text" name="sdiConfirm" id="sdiConfirm" style="width:240px;" value="#getCustomer.sdi#" maxlength="50"> 
                    <br /><span class="small">Please re-enter your full #getProvider.userAcctLabel#.</span>
                    <input type="hidden" name="fullSDI" id="fullSDI" value="" />
                </td>
              </tr>
              </cfif>
            </table>
        </div>
        <div class="panelheader">Billing Address</div>
        <div class="panelcontent">
            <input type="checkbox" name="sameBilling" id="sameBilling" value="Y" /> <label for="sameBilling" style = "color: black" >Same as Service Address</label>
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td class="formfieldlabel" width="180">Address: <span class="red small">*</span></td>
                <td><input type="text" name="billingAddress1" id="billingAddress1" style="width:240px;" value="#getCustomer.billingAddress1#"></td>
              </tr>
              <tr>
                <td class="formfieldlabel">Address (cont.):</td>
                <td><input type="text" name="billingAddress2" id="billingAddress2" style="width:240px;" value="#getCustomer.billingAddress2#"></td>
              </tr>
              <tr>
                <td class="formfieldlabel">City: <span class="red small">*</span></td>
                <td><input type="text" name="billingCity" id="billingCity" style="width:240px;" value="#getCustomer.billingCity#"></td>
              </tr>
              <tr>
                <td class="formfieldlabel">State: <span class="red small">*</span></td>
                <td style="vertical-align:middle;"><select name="billingState" id="billingState" style="width:240px;"><cfloop query="getStates"><option value="#stateCode#" <cfif stateCode EQ application.defaultState OR stateCode EQ getCustomer.billingState>selected</cfif>>#stateName#</option></cfloop></select></td>
              </tr>
              <tr>
                <td class="formfieldlabel">Zip Code: <span class="red small">*</span></td>
                <td><input type="text" name="billingZip" id="billingZip" style="width:240px;" value="#getCustomer.billingZip#"></td>
              </tr>
            </table>
        </div>
        <div style="text-align:center; padding-top:10px;"><input type="submit" value="Continue to Order Review" /></div>
        </cfoutput>
        </form>

        <cfelse>
        <p>&nbsp;</p>
        <div class="errormessage">Something went wrong. We weren't able to find your offer or it is no longer valid. <a href="../newcustomer.cfm">Please go back and search for current offers</a>.</div>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        </cfif>

是否有一个简单的解决方法或者它可能需要一个Javascript解决方案?谢谢

3 个答案:

答案 0 :(得分:0)

所以这对你不起作用?

<cfoutput>
     <form action="confirmOrder-solar.cfm?provider=#provider#" >
</cfoutput>

答案 1 :(得分:0)

中添加网址变量时
<form action="confirmOrder-solar.cfm?provider=#provider#" method="get">

我对ColdFusion的体验是它将URL剥离到CFM部分(在你的情况下为confirmOrder-solar.cfm),追加?跟随查询字符串,该字符串仅包含形式的字段。也就是说,忽略变量provider。

为了实现您想要的控制,我建议您使用Javascript。

答案 2 :(得分:0)

<cfhttp url="URL_of_domain/testpage.cfm?testVar1=0&testVar2=2"
      method="post">
<cfhttpparam type="formfield" name="x1" value="3" >
<cfhttpparam type="formfield" name="x2" value="4" >
</cfhttp>
<!---
The following variables exist on testpage.cfm:

URL.testVar1
URL.testVar2
FORM.x1
FORM.x2
--->