Coldfusion的Internet Explorer表单提交问题

时间:2011-09-07 22:53:06

标签: coldfusion internet-explorer-8

我有一个带有两个提交按钮的cfform,我的操作页面中的逻辑与safari,chrome,FF和IE9完美搭配。但IE8和更少有问题。在IE8或更低版本由于某种原因它似乎无法发送操作页面的提交按钮的值,所以它永远不会在我的任何if语句中。

表格代码:

<cfform action="appQuery.cfm?loc=personal" method="post" data-ajax="false">
            <label for="fName">First Name</label>
            <cfinput type="text" name="fName" value="#fName#" style="width: 200px;"><br>
            <label for="MI">Middle Initial</label>
            <cfinput type="text" name="MI" value="#MI#" maxlength="1" style="width: 40px;"><br>
            <label for="lName">Last Name</label>
            <cfinput type="text" name="lName" value="#lName#" style="width: 200px;"><br>
            <label for="dob">Date Of Birth Ex. 03/13/94</label>
            <cfinput type="text" name="dob" maxlength="8" value="#dob#" style="width: 100px;"><br>
            <fieldset data-role="controlgroup" data-type="horizontal" >
                <legend>Gender</legend>
                <label for="1">Female</label>
                <input type="radio" value="Female" name="gender" id="1" <cfif #gender# eq "Female">checked</cfif> >
                <label for="2">Male</label>
                <input type="radio" value="Male" name="gender" id="2" <cfif #gender# eq "Male">checked</cfif>>
            </fieldset>
            <div data-role="fieldcontain">
                <label for="ethnicity" class="select">Choose Ethnicity</label>
                <select name="ethnicity" id="ethnicity" data-native-menu="false" data-inline="true" class="eth" onChange="change()">
                    <option value="Hispanic" <cfif #Ethnicity# eq "Hispanic">selected</cfif>>Hispanic</option>
                    <option value="African American" <cfif #Ethnicity# eq "African American">selected</cfif>>African American</option>
                    <option value="Asian/Pacific Islander" <cfif #Ethnicity# eq 'Asian/Pacific Islander'> selected</cfif>>Asian/Pacific Islander</option>
                    <option value="Caucasian" <cfif #Ethnicity# eq "Caucasian"> selected</cfif>>Caucasian</option>
                    <option value="Other" id="other">Other</option>
                </select>
            </div>
            <div id="ethCustom" style="visibility:hidden;" data-role="fieldcontain">
                <label for="ethOther">Ethnicity</label>
                <cfinput type="text" name="ethOther" style="width: 200px;" /><br>
            </div>
            <cfinput type="submit" data-inline="true" value="Save and Contiune Later" name="submit"  />
            <cfinput type="submit" data-inline="true" value="Save and Contiune Now" name="submit" />
        </cfform>

行动页面:

<cfif #URL.loc# eq "personal" AND #FORM.submit# eq "Save and Contiune Now">
    <cfquery datasource="#dbname#" username="#dbuser#" password="#dbpass#" name="personal1">
    UPDATE student
    SET  fName = '#FORM.fName#', lName = '#FORM.lName#', MI = '#FORM.MI#', dob = '#FORM.dob#', gender = '#FORM.gender#',<cfif #FORM.ethnicity# eq "Other"> Ethnicity = '#FORM.ethOther#'<cfelse> Ethnicity = '#FORM.ethnicity#'</cfif>
    WHERE s_id = '#COOKIE.id#'
    </cfquery>
    <cflocation url="appProcess.cfm##contact" addtoken="no">
<cfelseif #URL.loc# eq "personal" AND #FORM.submit# eq "Save and Contiune Later">
    <cfquery datasource="#dbname#" username="#dbuser#" password="#dbpass#">
    UPDATE student
    SET  fName = '#FORM.fName#', lName = '#FORM.lName#', MI = '#FORM.MI#', dob = '#FORM.dob#', gender = '#FORM.gender#',<cfif #FORM.ethnicity# eq "Other"> Ethnicity = '#FORM.ethOther#'<cfelse> Ethnicity = '#FORM.ethnicity#'</cfif>
    WHERE s_id = '#COOKIE.id#'
    </cfquery>
    <cflocation url="http://.com/logout.cfm" addtoken="no”>
</cfif>

我是否有不同的方法可以有条件地检查哪个按下的提交按钮是IE友好的?

3 个答案:

答案 0 :(得分:1)

请查看以下编码。希望它可以帮到你。

表单页

<script>
<!-- 
    function clickbtnSubmit(obj) {
        document.myForm.btnPress.value = obj;
    }
 -->
</script>

<cfform name="myForm" action="[yourActionPage]" method="post" data-ajax="false">
    <input type="Hidden" name="btnPress">
    ...
    ...
    ...
    <cfinput type="submit" data-inline="true" value="Save and Contiune Later" onclick="clickbtnSubmit(this.value)" name="submit"  />
    <cfinput type="submit" data-inline="true" value="Save and Contiune Now" onclick="clickbtnSubmit(this.value)" name="submit" />
</cfform>

操作页面

<cfdump var="#form#">

答案 1 :(得分:0)

您可以将提交更改为按钮,然后在按下任何按钮时点击一下,更改隐藏的表单字段然后提交。

或者,只需将两个提交按钮更改为无线电输入?

答案 2 :(得分:0)

不确定这是否有帮助:我正在使用IE版本8.0.6001.18702,我注意到当我按下回车键而不是按“提交”按钮时,提交按钮没有通过。我在Chrome或Firefox中没有此问题。一个简单的解决方法是创建一个隐藏的虚拟字段来传递和检查值,只需要在同一个CF页面上添加一行并更改一行。

这两行是:
1.在你传递隐藏字段的位置添加一行来传递虚拟字段(参见最后一行旁边;我使用变量名称输入)
2.在代码顶部添加虚拟值存在的检查“form.enter”(参见示例代码的第一行)

示例代码:my_edit_page.cfm

<cfif isdefined("form.update") OR isdefined("form.enter")>
    <cfquery datasource="my_datasource" result="sqlerrm">
         [enter your SQL here]
     </cfquery>
     <cflocation url="my_edit_page.cfm?id=#url.id# />
</cfif>
 :
 :            
<cfform action="my_edit_page.cfm" method="post">

         :
     <input type="submit" class="btn btn-primary" name="update" value="Update" />
     <input type="hidden" name="my_field" value="#myquery.my_field#" /> 
     <input type="hidden" name="enter" value="enter" />
</cfform>
: