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?  
LVL 1
LC7WebAsked:
Who is Participating?
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.

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

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
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
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.