开发者

Checking multiple forms for submission on the same page in coldfusion

开发者 https://www.devze.com 2023-01-07 22:22 出处:网络
Hello again stackoverflow... Once again I have a troublesome problem. I have a page where I am using jQuery tabs to divide up three update forms. (Two really, one is a cfgrid so it doesn\'t really co

Hello again stackoverflow...

Once again I have a troublesome problem. I have a page where I am using jQuery tabs to divide up three update forms. (Two really, one is a cfgrid so it doesn't really count.) Basically, when you submit the first form tab it is fine. However, if you submit the last form, it submits and refreshes the page but nothing was updated.

I've determined it has something to do with identifying which form is being submitted.

Note: These forms are being submitted to same page they are on so I am using this method:

<cfif isdefined("form.submit")>
//database stuff etc
</cfif>

I am submitting the forms by doing this at the end:

<input type="submit" name="submit" id="button"  value="Save Changes" onclick = "form.submit()" />

After determining it had something to with identifying which form is being submitted, I changed the button to be:

<input type="submit" name="submit" id="button"  value="Save Changes" onclick = "document.forms["form3"].submit()" />

I'm not sure if this is the mos开发者_运维问答t efficient way to do this...and I'm not sure how to specific that form3 is being submitted in the coldfusion part...I tried:

<cfif isdefined("form3.submit")>

but this doesn't work. It does not follow through the code.

Note: I'm using coldfusion 8. Also, using CFAJAX tags are limited because our ITS department didn't set up coldfusion correctly on the server...and they don't believe me. Thus I'm kind forced to do it in this ...weird way. It only support cfgrid for some weird reason...


ColdFusion (nor any server-side language) does not know what ID your forms might have - it only knows what you submitted via input (and select/textarea/etc) fields, and puts it in the form scope.

To do what you want, you need to have forms somthing along the lines of:

<form>
    ....
    <input type="submit" name="submit1" value="Save Changes"/>
</form>

<form>
    ....
    <input type="submit" name="submit3" value="Save Changes"/>
</form>

Then on the CF side you check which form it is with:

<cfif StructKeyExists(Form,'Submit1')>
...
</cfif>

or

<cfif StructKeyExists(Form,'Submit3')>
...
</cfif>


Hah, I figured it out! You have to make the submit names different on each form.

<input type="submit" name="submitDoc" id="button"  value="Save Changes" onclick = "document.forms["form3"].submit()" />

I just changed the submit name to submitDoc

<cfif isdefined("form.submitDoc")>

Works!

0

精彩评论

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

关注公众号