Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple image submit buttons

Status
Not open for further replies.

brennke

Programmer
May 2, 2000
11
US
Hello All,<br><br>&nbsp;&nbsp;I am trying to incorporate at least two submit buttons<br>(input type=image) on a shopping cart page I am building to submit the info thru a form.<br>I need for each one to specify an action value.<br><br>I can use the hidden field to pass the action value,<br>but this works for only one image submit button on a page.<br><br>My code so far:<br>&lt;cfform action=&quot;#thisPage##queryString#do=action&shortname=#url.shortname#&quot;&gt;<br><br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;updatebutton&quot; SRC=&quot;images/shop_updateprice.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot;&gt;<br>&lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;action&quot; VALUE=&quot;updateprice&quot;&gt;<br><br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;addtobutton&quot; SRC=&quot;images/shop_addtocart.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot;&gt;<br>&lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;action&quot; VALUE=&quot;addtobasket&quot;&gt;<br><br>Thanks in advance..
 
Try giving the image input tags the same name and different values...<br><br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;button&quot; <b>VALUE=&quot;updateprice&quot;</b> SRC=&quot;images/shop_updateprice.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot;&gt;<br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;button&quot; <b>VALUE=&quot;addtobasket&quot;</b> SRC=&quot;images/shop_addtocart.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot;&gt;<br><br>Then in the action page, just check the &quot;button&quot; value to perform the desired action.....<br><br>Let me know if this works...<br><br>DarkMan
 
Hey Hello Darkman,<br><br>&nbsp;&nbsp;Thanks ever so much for the response, but it seems, based upon my research & I tried it again, that the image type INPUT tag ignores the VALUE attribute (passes on a location coordinate thru the browser instead). I think some kind of <br>CFIF statement that sets the FORM.ACTION attribute, or selects a HIDDEN INPUT to include, based upon the NAME value of the INPUT-IMAGE tag might do it, but I'm a little off on the syntax so far. <br><br>I'll try to muddle thru, but am wide-open to suggestions,<br>and this would seem to be a very handy trick if we-all can figure it out.
 
hmmmm.....<br><br>How about this:<br><br>on the form<br><FONT FACE=monospace>.....<br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;updatebutton&quot; SRC=&quot;images/shop_updateprice.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot;&gt;<br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;addtobutton&quot; SRC=&quot;images/shop_addtocart.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot;&gt;</font><br><br>Then on the action page...<br><FONT FACE=monospace>&lt;cfparam name=&quot;updatebutton&quot; default=&quot;&quot;&gt;<br>&lt;cfparam name=&quot;addtobutton&quot; default=&quot;&quot;&gt;<br>&lt;cfif updatebutton is not &quot;&quot;&gt;<br>&lt;!--- update code ---&gt;<br>&lt;cfelseif addtobutton is not &quot;&quot;&gt;<br>&lt;!--- add to code ---&gt;<br>&lt;/cfif&gt;</font><br><br>Again, let me know if this works...:)<br><br>DM
 
Zoot Allures !<br><br>&nbsp;&nbsp;Well, my bruising continues..<br>&nbsp;&nbsp;What I get (and have been getting) is the error msg:<br>Error resolving parameter ACTION<br><br>My sticking point is setting the value af &quot;action&quot;<br>which is passed thru the URL in the CFFORM tag.<br>I have tried placing the update code on the application page and the catalog page.&nbsp;&nbsp;thanks again and again.<br><br>My current flow is something like this<br>For brevity, Ill just list the code for the updateprice<br>image button<br><br>relevant code on catalog page:<br>&lt;cfparam name=&quot;updatebutton&quot; default=&quot;&quot;&gt;<br><br>&lt;cfform action=&quot;#thisPage##queryString#do=action&shortname=#url.shortname#&quot; method=&quot;post&quot;&gt;<br><br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;updatebutton&quot; SRC=&quot;images/shop_updateprice.gif&quot;&gt;<br><br>&lt;cfif updatebutton is not &quot;&quot;&gt;<br>&lt;cfset action=&quot;updateprice&quot;&gt; <br>&lt;/cfif&gt;<br><br><br>relevant code on application page:<br><br>&lt;cfif isdefined(&quot;url.do&quot;)&gt;<br>&lt;cfset session.do = url.do&gt;<br><br>&lt;cfif session.do is &quot;action&quot;&gt;<br>&lt;!--- Handle events ---&gt;<br><br>&lt;cfif action is &quot;checkout&quot;&gt;<br>&lt;cfset session.do = &quot;form&quot;&gt;<br>&lt;cfelseif action is &quot;updateprice&quot;&gt;<br>&lt;cf_storefront_configure<br>dsn=&quot;#attributes.dsn#&quot;<br>action=&quot;updateprice&quot;<br>shortname=&quot;#url.shortname#&quot;&gt;<br><br><br>
 
Yo Darkman !..<br><br>&nbsp;&nbsp;Hey I'm on my way to a meeting right now, but I just wanted to let you know I found the Holy Grail on this..<br>I will post a detailed message tomorrow explaining how to crack this coconut.<br><br>Thanks a bazillion again for taking an interest in my plight.&nbsp;&nbsp;I'll share with everryone tomorrow !<br><br>ciao... BRR
 
In conclusion...<br><br>I blasted out a search on every search engine I could find & found this JEWEL.<br><br>Finished, relevant code as follows all on catalog page:<br><br>&lt;!--- cfform tag and associated hidden input ---&gt;<br>&lt;CFFORM NAME=&quot;configurate&quot; ACTION=&quot;#thisPage##queryString#do=action&shortname=#url.shortname#&quot; METHOD=&quot;post&quot;&gt;<br><br>&lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;action&quot; VALUE=&quot;&quot;&gt;<br><br><br>&lt;!--- image input tags with onclick expressions ---&gt;<br><br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;updatebutton&quot; SRC=&quot;images/shop_updateprice.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot; ONCLICK='document.configurate.action.value=&quot;updateprice&quot;;document.configurate.submit()'&gt;<br>&lt;/td&gt;<br>&lt;/tr&gt;<br>&lt;tr&gt;<br>&lt;td&gt;<br>&lt;INPUT TYPE=&quot;image&quot; NAME=&quot;updatebutton&quot; SRC=&quot;images/shop_addtocart.gif&quot; WIDTH=&quot;97&quot; HEIGHT=&quot;31&quot; BORDER=&quot;0&quot; ONCLICK='document.configurate.action.value=&quot;addtobasket&quot;;document.configurate.submit()'&gt;<br><br>ohmigawd- it works !<br>seems the key pieces are that the CFFORM tag has a NAME<br>attribute & the hidden Input tag establishes the &quot;NAME&quot; half of the NAME-VALUE PAIR. Then the onclick elements tie in the &quot;VALUE&quot; half of it.<br><br>I can get on with my life now..&nbsp;&nbsp;but I'll be back..<br>ciao.. Bruce Rojas-Rennke<br><br><br><br><br>
 
I am trying to apply method on my page but cannot seem to get it working, can you tell me what does <br>&quot;ACTION=&quot;#thisPage##queryString#do=action&shortname=#url.shortname#&quot; &quot;<br>in your cfform do, because my action part only has the file name, and thats it, can you shed some light on this.<br><br>Thanx heaps<br><br>
 
Hello Tempoman,<br><br>&nbsp;&nbsp;That part of the code in the url is passing info to my application page. Basically, I am posting the form to the<br>the same page it originates on (storefront_configure.cfm).<br>CF will look at the application page first everytime<br>(storefront.cfm), and then proceed to where it is directed<br>(back to storefront_configure.cfm in this case).<br><br>&nbsp;If you are using an application page, you can use the URL parameters to trigger events there, or simply post the form back to the page of origination. I can also send you those two pages if you'd like a closer look at the code. I used Ben Forta's Quickstore example in his book (Web Application<br>Construction Kit) as my original model.<br><br>&nbsp;&nbsp;ciao.. Bruce
 
Could you send me to code to my email address please.<br>my email address is:<br><br><A HREF="mailto:tempoman_pent@yahoo.com">tempoman_pent@yahoo.com</A><br><br>Thanx alot<br><br>
 
Hello Everyone:<br><br>I was wondering if there was a work around in Netscape for the multiple image submit buttons in Cold Fusion.<br><br>The information brennke wrote was very helpful.<br><br>Thanks
 
Hi, I'm new to CF (3 weeks) and I had the same problem as the one above (I think). My solution shows below and it works well enough for me to go on to my next problem. Was my solution a) wrong, b) overkill, c) nothing to do with the above problem or d) more work than I needed to do.

What ever the answer, the first solution solved my imediate problem. Thanks to all.
Brian
belefant@jhu.edu

<CFform action = &quot;GoToServer1.cfm&quot; METHOD=&quot;POST&quot;>
<CENTER>
<CFIF ServerNumber IS 1>
<INPUT TYPE=&quot;IMAGE&quot; NAME=&quot;ws1&quot; SRC=&quot;green5.gif&quot;>
</CFIF>
</CENTER>
</CFform>
<CFform action = &quot;GoToServer2.cfm&quot; METHOD=&quot;POST&quot;>
<CENTER>
<CFIF ServerNumber IS 2>
<INPUT TYPE=&quot;IMAGE&quot; NAME=&quot;ws2&quot; SRC=&quot;green5.gif&quot;>
</CFIF>
</CENTER>
</CFform>
<CFform action = &quot;GoToServer3.cfm&quot; METHOD=&quot;POST&quot;>
<CENTER>
<CFIF ServerNumber IS 3>
<INPUT TYPE=&quot;IMAGE&quot; NAME=&quot;ws3&quot; SRC=&quot;green5.gif&quot;>
</CFIF>
</CENTER>
</CFform> [sig][/sig]
 
I think I have an easier way to do this. If you have multiple image buttons on the screen, whichever one is clicked will have two related CF variables passed on to the next page. The two variables are the x and y locations as to where the image was clicked.

On the form page:
<INPUT TYPE=&quot;IMAGE&quot; NAME=&quot;Image1&quot; SRC=&quot;Image1.gif&quot;>
<INPUT TYPE=&quot;IMAGE&quot; NAME=&quot;Image2&quot; SRC=&quot;Image2.gif&quot;>

On the goto page:
<CFIF isDefined(&quot;FORM.Image1.x&quot;)>
Image 1 was clicked
<CFELSEIF isDefined(&quot;FORM.Image2.x&quot;)>
Image 2 was clicked
</CFIF>

This works well for me since it is completely Coldfusion based. If someone gives this a try let me know how it works out! ;-) [sig][/sig]
 
I did it this way. Hope that will help someone.

<CFFORM ACTION=&quot;yuhuuuuu.cfm&quot; METHOD=&quot;POST&quot; name=&quot;davor&quot;>

.
.
.
.


<!-- this is just to create object name choice-->
<input type=&quot;hidden&quot; name=&quot;choice&quot; value=&quot;abrakadabra&quot;>

<img src=&quot;../com/unos.gif&quot; onClick=&quot;document.davor.choice.value='unos'; document.davor.submit();&quot; >

<img src=&quot;../com/snimi.gif&quot; onClick=&quot;document.davor.choice.value='snimi'; document.davor.submit();&quot; >

</cfform>
 
A star for AMayer! I have been wondering what those x and y values meant for some time; ever since setting my CF Admin on debug and seeing them passed back from VeriSign's payment processor when &quot;echodata&quot; was set to &quot;TRUE&quot;. So that's it! Thanks.

By the way, a caution to everyone using &quot;onClick&quot; events and image buttons to submit forms. I may have wrongly implemented it, but in certain browsers, this caused a &quot;double entry&quot; of the form. When a shopper pressed &quot;Add to Cart&quot;, two items were added instead of one. I think the Explorer 5s were implicated. Maybe 6, too. You might want to check this out. John Hoarty
jhoarty@quickestore.com
 
FYI:

The x and y in an image submit button represent the Cartesian pixel coordinates within the image that the user clicked. - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top