Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

Image Form Button Error's

Hello,

I have a problem with a image type submit button.  The original code is:

<input class="buttonstyle" type="button" value="<% WriteString("FormButton_Checkout") %>" name="btnCheckout" onClick="alert('<% WriteString("Popup_OrderBelowMin")%> (<% =aryCurrencies(1) & " " & CurrencyDisplay(Application(LICENSENUMBER & "minorderval"), aryCurrencies(3), aryCurrencies(4)) %>)')"><% Else %><input class="buttonstyle" type="submit" value="<% WriteString("FormButton_Checkout") %>" name="btnCheckout"><% End If %>

New Code with input type=image:

<input type="image" src="purchase.gif" value="<% WriteString("FormButton_Checkout") %>" name="btnCheckout" onClick="alert('<% WriteString("Popup_OrderBelowMin")%> (<% =aryCurrencies(1) & " " & CurrencyDisplay(Application(LICENSENUMBER & "minorderval"), aryCurrencies(3), aryCurrencies(4)) %>)')"></span><% Else %><input type="image" src="purchase.gif" value="<% WriteString("FormButton_Checkout") %>" name="btnCheckout"><% End If %>

The Image shows up, but the button does not work when clicked.  Is it not possible to set this type of button as an image?  
0
LC7Web
Asked:
LC7Web
1 Solution
 
Diablo84Commented:
When you say it doesn't work do you mean its not submitting or it is submitting but your data isnt being processed?

I suspect the latter in which case if your processing is restricted to a conditional and if that conditional is that btnCheckout is set (ie. is clicked) then you must reference it using:

btnCheckout_x

or:

btnCheckout_y

not just btnCheckout.
0
 
eyeh8uCommented:
It's important to note that the onclick event of an image input type must return true or false.

By default, clicking one of these inputs will submit the form they belong to, the onclick event allows you to put validation into the form, so return false if you don't want it to submit the form.

<form method="Post" action="test.asp">
<input type="image" src="button.gif" onclick="alert('here');" name="btnCheckout">
</form>

That will display here in an alert box fine, but the form will then submit anyway.


<form method="Post" action="test.asp">
<input type="image" src="button.gif" onclick="alert('here');return false;" name="btnCheckout">
</form>

That won't submit the form, but will still display here.

Now your code is hard to figure out as I don't have the rest of the ASP in place to use /EXACTLY/ what you have in your form, but I suspect the javascript being output here:

onClick="alert('<% WriteString("Popup_OrderBelowMin")%> (<% =aryCurrencies(1) & " " & CurrencyDisplay(Application(LICENSENUMBER & "minorderval"), aryCurrencies(3), aryCurrencies(4)) %>)')"

Is throwing an error, and you aren't seeing it as you have IE set to supress errors, and then the form is submitted.

View the source of the HTML that is being rendered and check what is in the onClick event of the rendered form.

I did this:
<input type="image" src="purchase.gif" value="FormButton_Checkout" name="btnCheckout" onClick="alert('Popup_OrderBelowMin(4 0.8,0.2, 0.1)')">

As a wild stab in the dark for what your functions actualy return, and I got the alert as expected.
 
But looking now I think that's definatly not what you are producing:

<% =aryCurrencies(1) & " " & CurrencyDisplay(Application(LICENSENUMBER & "minorderval"), aryCurrencies(3), aryCurrencies(4)) %>

Seens to produce a string that looks like "xx yy" (without the quotes) where xx is the value of aryCurrencies(1) and yy is the result of your currency display. SO your actual code might end up looking like:

<input type="image" src="purchase.gif" value="FormButton_Checkout" name="btnCheckout" onClick="alert('Popup_OrderBelowMin(4 0.8)')">

But I can't really tell as I dont' know what's in the array or the function result. If it's outputting any quotes and you get something like
<input type="image" src="purchase.gif" value="FormButton_Checkout" name="btnCheckout" onClick="alert('Popup_OrderBelowMin(4 "$5.99")')">

Then the quotes will break the syntax of the onclick handler, you'll have a javascript error, and if IE supresses that you won't know what's gone wrong.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now