IE not handling multiple submit buttons in a coldfusion form

Hello all,

      I have a form in a coldusion page that has two different submit buttons; both of type submit but with different value tags.  One has value "edit" and one has value "submitOK".  Now on the page the form gets posted to i want to evaluate the value of that form element: as in:

<cfelseif #form.submit# EQ "edit">

Now, this works in firefox no problem; but in IE it says that the form element "submit" does not exist; can someone tell me why, and how I can fix it?  Thanks in advance.
LVL 1
andrewaielloAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dl8453Commented:
You can verify what is being submitted by pasting this into the form you are submitting to:

<cfloop index="thefield" list="#form.fieldnames#">
    <cfset fields="#thefield# = #evaluate(thefield)#">
    <cfoutput>#fields#</cfoutput><br>
</cfloop>

<cfif form.submit CONTAINS "edit">
action
<cfelseif form.sbumit contains "submitok">
other action
</cfif>
0
dl8453Commented:
Sorry about that, I did not remove the first part of my text... what I think you are looking for is CONTAINS.

<cfif form.submit CONTAINS "edit">
action
<cfelseif form.sbumit CONTAINS "submitok">
other action
<cfelse>
aother action
</cfif>
0
andrewaielloAuthor Commented:
No go; still gives the error "Element SUBMIT is undefined in FORM. "   in IE
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

dl8453Commented:
Oh my, there it is, you need to change your form method to POST instead of GET.

<form action="" method="post">
0
andrewaielloAuthor Commented:
it was post
0
dl8453Commented:
Paste this into a new document and see if you still have issues.  This is about as bare bones as you can get.  I'm assuming you have checked your spelling?  ;)

<form action="" method="post">
<input type="submit" name="btnContinue" value="edit" /> <input type="submit" name="btnContinue" value="submitOK" />
</form>

<cfif isdefined('btnContinue')>
      <cfif form.btnContinue eq "edit">
      Editing
      <cfelseif form.btnContinue eq "submitOK">
      Submit OK
      <cfelse>
      Error
      </cfif>      
</cfif>
0
andrewaielloAuthor Commented:
yeah thast fine...   Perhaps its because my submits are image types?  for instance here are the two submit buttons:

<input name="submit" type="image" value="submitOK" src="images/button-submit.jpg">

<input name="submit" type="image" value="edit" src="images/button-edit.jpg">
0
dl8453Commented:
Yes, type = image does make a difference.  If you are just confirming a screen prior to checking out (for example), you can use OnClick="submit();" or OnClick="location.href='nextpage?submit=submitOK&vars=values';" or OnClick="location.href='nextpage?submit=edit&vars=values';"

You can also employ JavaScript but I think that would make your page way more complicated than it needs to be.  Just depends on if you need to use Form Validation and so forth.
0
andrewaielloAuthor Commented:
the form has about 50 values so that would like suck to add them all in that string....
0
SidFishesCommented:
the reason is that both your submits are named submit (forms properly don't use id they use name)

try this

<input name="submitOK" type="image" value="submitOK" src="images/button-submit.jpg">
<input name="edit" type="image" value="edit" src="images/button-edit.jpg">



<cfif isdefined('form.submitok')>


<cfelse>


</cfif>

or

<cfif isdefined('form.submitok')>



</cfif>

<cfif isdefined('form.edit')>



</cfif>

you could add others in this case like

<cfif isdefined('form.delete')>



</cfif>
0
bwasyliukCommented:
How about using some javascript to set the value of a hidden field.  Then read the value of the hidden field on your processing page.

<input type="hidden" name="submitvalue" value="" />

<input name="submit" type="image" value="submitOK" OnClick="document.forms[0].submitvalue.value='submitOK';" src="images/button-submit.jpg">
<input name="submit" type="image" value="edit" OnClick="document.forms[0].submitvalue.value='edit';" src="images/button-edit.jpg">

Just thowing sample code above to get the idea accross - have not tested...

Ben
www.ScheduleForce.net
0
SidFishesCommented:
oh...and value="submitOK" of a submit button properly does nothing except provide text for the button

to test this just do this

<form method="post" action="thisform.cfm">
<input type = "submit" value="Test">
<cfdump var="#form#">
</form>

 and then try

<form method="post" action="thisform.cfm">
<input type = "submit" value="Test"  name="test">
<cfdump var="#form#">
</form>

you'll see the first passes nothing to the form scope
0
SidFishesCommented:
and i guess if you want to test that id doesn't pass to form scope either...

<form method="post" action="index.cfm?fuseaction=Website.dsp_UPdateTables">
<input type = "submit" value="Test" id="test">
<cfdump var="#form#">
</form>
0
SidFishesCommented:
c&p error

<form method="post" action="index.cfm?fuseaction=Website.dsp_UPdateTables">

sb

<form method="post" action="thisform.cfm">

0
andrewaielloAuthor Commented:
I see Sid; that makes sense
0
andrewaielloAuthor Commented:
Okay said; i tried that and its strange;  It still works dandy in firefox but not in IE;  it no longer gives an error but the if statements always fail.
0
SidFishesCommented:
add a dump before your cfif's

<cfdump var="#form#">

what do you see
0
andrewaielloAuthor Commented:
Ahh useful trick... and yes i see an issue, submit okay is not there; for some reason the last form values are:  "EDIT.X,EDIT.Y,EDIT"   which is weird.
0
SidFishesCommented:
can you post your submit button code again...
0
andrewaielloAuthor Commented:
<input name="submitOK" type="image" value="submitOK" src="images/button-submit.jpg">

<input name="edit" type="image" value="edit" src="images/button-edit.jpg">
0
dgrafxCommented:
your image submit buttons (images) will be named X & Y etc ...
Why?
I've never found an answer - but haven't looked for one for many moons.
And this may only be in IE - don't recall.

If you don't mind using javascript:
<form name="Form" ...
<input type="hidden" name="test" value="submit">
<input  type="image" value="submitOK" src="images/button-submit.jpg" onclick="test.value='submit'">
<input type="image" value="edit" src="images/button-edit.jpg" onclick="test.value='edit'">

then you just test the value of form.test
<cfif form.test is "submit">
do this
<cfelseif form.test is "edit">
do that
<cfelse>
invalid - go back to form
</cfif>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pmascariCommented:
Going to throw my two cents in....

The problem is that you have no form field named SUBMIT on your form.  That is the type of field...not the name.  Make sure each of your submit buttons has a NAME attribute and that each is different.  Let's say you have:

<input type="submit" name="edit" value="edit">
<input type="submit" name="submitOK" value="submitOK">

On the receiving page, put two CFPARAM tags like so:

<cfparam name="form.submitOK" default="">
<cfparam name="form.edit" default="">

No your CFIF tags should be something like:

<cfif form.submitOK is "submitOK">
      Do something
<cfelseif form.edit is "edit">
      Do something
<cfelse>
      Do something
</cfif>

The reason you get "EDIT.X,EDIT.Y,EDIT" is because you use images as you form's submit.  Those X and Y values are the exact coordinates, ON THE IMAGE ITSELF, where you clicked.  These can come in useful in mapping applications or something similar but you can ignore them usually.


Good luck

0
dgrafxCommented:
pmascari
he has already named the submits right from the start ...

andrew
I just kinda posted something without asking why you want to do this.
I mean - if they want to edit - can't they just type the edited values into the form fields?
Then click submit?
Or is this form not showing form fields?
And if not - then why not have your submit button submit the form and
have and edit button (image) that when clicked does NOT submit but loads the edit form.
like:
<img src="images/button-edit.jpg" onclick="location.replace('editform.cfm?action=edit')">
for ex.
0
andrewaielloAuthor Commented:
Hey guys,  

      The scenario was basically they fill out a long form; and when it submits it goes to a page that shows the info they just put in (but not in form fields, like in a designed page where the text fields is not in a form...it would have made it easeir if it was...)  and then they can click edit to go back to the previous page (all fields still populated) or submit it.    Anyway, thanks to all your help i got it working now lol.  Thanks!
0
dgrafxCommented:
glad you got it working
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.