开发者

Internet Explorer Form Submission issues with Coldfusion

开发者 https://www.devze.com 2023-04-03 21:32 出处:网络
I have a cfform with two submit buttons, the logic in my action page works perfectly fine with safari, chrome, FF, and IE9. But IE8 and less are having issues.in IE8 or less for some reason it can’t

I have a cfform with two submit buttons, the logic in my action page works perfectly fine with safari, chrome, FF, and IE9. But IE8 and less are having issues.in IE8 or less for some reason it can’t seem to send the action page the value of the submit button, so it never makes it inside any of my if statements.

Form Code:

<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>

Action page:

<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 = '#F开发者_开发百科ORM.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>

Is there a different way I could conditionally check for which submit button that was pressed that is IE friendly?


Please check it out the following coding. Hope it can help you.

Form Page

<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>

Action Page

<cfdump var="#form#">


You could change the submits to buttons, then catch an onclick on whichever button was pressed, change a hidden form field then submit.

Or, just change the two submit buttons into radio inputs?


Not sure if this will help: I'm using IE version 8.0.6001.18702 and I noticed the submit button is not passed when I pressed the enter key instead of pressing the "submit" button. I don't have this problem in Chrome or Firefox. A simple fix is to create a hidden dummy field to pass and check for the value which only requires you to add one line and change one line on the same CF page.

The 2 lines are:
1. Passing of a dummy field by adding one line where you pass the hidden field (see next to last line; I used the variable name enter)
2. Add the checking of the existence of the dummy value, "form.enter" at the top of your code (see first line of sample code)

Sample code: 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>
:
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号