Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IE not handling multiple submit buttons in a coldfusion form

Posted on 2007-04-10
25
Medium Priority
?
1,327 Views
Last Modified: 2013-12-24
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.
0
Comment
Question by:andrewaiello
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 5
  • +3
25 Comments
 
LVL 1

Expert Comment

by:dl8453
ID: 18884680
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
 
LVL 1

Expert Comment

by:dl8453
ID: 18884696
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
 
LVL 1

Author Comment

by:andrewaiello
ID: 18884834
No go; still gives the error "Element SUBMIT is undefined in FORM. "   in IE
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 1

Expert Comment

by:dl8453
ID: 18884880
Oh my, there it is, you need to change your form method to POST instead of GET.

<form action="" method="post">
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18885059
it was post
0
 
LVL 1

Expert Comment

by:dl8453
ID: 18885080
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
 
LVL 1

Author Comment

by:andrewaiello
ID: 18885253
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
 
LVL 1

Expert Comment

by:dl8453
ID: 18885360
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
 
LVL 1

Author Comment

by:andrewaiello
ID: 18885398
the form has about 50 values so that would like suck to add them all in that string....
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 18885422
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
 
LVL 7

Expert Comment

by:bwasyliuk
ID: 18885442
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 18885469
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 18885504
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 18885521
c&p error

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

sb

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

0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18885524
I see Sid; that makes sense
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18885594
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 18885623
add a dump before your cfif's

<cfdump var="#form#">

what do you see
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18885708
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 18885722
can you post your submit button code again...
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18885776
<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
 
LVL 25

Accepted Solution

by:
dgrafx earned 500 total points
ID: 18886294
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
 
LVL 8

Expert Comment

by:pmascari
ID: 18891355
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
 
LVL 25

Expert Comment

by:dgrafx
ID: 18891533
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
 
LVL 1

Author Comment

by:andrewaiello
ID: 18898094
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
 
LVL 25

Expert Comment

by:dgrafx
ID: 18898123
glad you got it working
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question